-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(events): group CW Event Targets in module (#2576)
Move new event targets into `@aws-cdk/aws-events-targets` - CodePipeline - EC2 task - StepFunctions StateMachine Invocation payloads are now under the control of the target classes, so that targets for which the payload maps onto API calls (such as ECS, CodeBuild, etc) can specify the API parameters directly as props. `EventTargetInput` is a union class with three variants, allowing serialization of strings, multiline strings and objects. Target inputs support a special type of Token (`EventField`) which can be used to refer to fields from the event, instead of value literals. A number of predefined events and the fields that they have available have been defined, so that accessing them becomes even more convenient (`StageChangeEvent`, `PhaseChangeEvent`, `ReferenceEvent`). To be able to use Tokens to implement EventInput substitution, add a refactoring and more principaled separation of concerns in the Token code. Resolution can now be more easily hooked, CloudFormation-aware string concatenation is implemented using a plugin, and Token callbacks receive an `IResolveContext` which they can use to resolve deeper (and will reuse the same settings that the resolver was started with). We should as good as be able to get rid of `stack.node.resolve()` in the near future. ALSO: - Simplified `LatestDeploymentResource` to use existing logical ID overriding features. - Add an `onEvent()` method to `CloudTrail`. - Fix API misuse in the rendering of a CodePipeline, where Token rendering would lead to stateful side effects. Make Actions render out their region directly, if set, without requiring overrides. - In ECS task `assignPublicIp` now defaults to `undefined`, instead of `DISABLED`, to align with service API. - Fix a bug in Token resolution where Tokens returning fresh `CfnReference` objects upon resolution would fail to be detected during cross-stack reference analysis; `CfnReference` now has static methods that return singleton objects. - Get rid of an extra "resolve" call in `CfnResource.toCloudFormation()`. We can now use `PostProcessToken` to apply the property renames and output validation we were originally doing the resolve for. Fixes #2403, fixes #2404, fixes #2581. BREAKING CHANGES * `@aws-cdk/aws-codepipeline.Pipeline` is no longer an event target itself, use `@aws-cdk/aws-events-targets.CodePipeline` instead. * `@aws-cdk/aws-stepfunctions.StateMachine` is no longer an event target itself, use `@aws-cdk/aws-events-targets.SfnStateMachine` instead. * `@aws-cdk/aws-ecs.Ec2RunTask` has been renamed to `@aws-cdk/aws-events-targets.EcsEc2Task`. * `CloudFormationJSON.stringify()` is now renamed to `CloudFormationLang.toJSON()`.
- Loading branch information
Showing
98 changed files
with
2,308 additions
and
1,394 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import events = require('@aws-cdk/aws-events'); | ||
|
||
/** | ||
* Event fields for the CodeBuild "state change" event | ||
* | ||
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-build-notifications.html#sample-build-notifications-ref | ||
*/ | ||
export class StateChangeEvent { | ||
/** | ||
* The triggering build's status | ||
*/ | ||
public static get buildStatus() { | ||
return events.EventField.fromPath('$.detail.build-status'); | ||
} | ||
|
||
/** | ||
* The triggering build's project name | ||
*/ | ||
public static get projectName() { | ||
return events.EventField.fromPath('$.detail.project-name'); | ||
} | ||
|
||
/** | ||
* Return the build id | ||
*/ | ||
public static get buildId() { | ||
return events.EventField.fromPath('$.detail.build-id'); | ||
} | ||
|
||
public static get currentPhase() { | ||
return events.EventField.fromPath('$.detail.current-phase'); | ||
} | ||
|
||
private constructor() { | ||
} | ||
} | ||
|
||
/** | ||
* Event fields for the CodeBuild "phase change" event | ||
* | ||
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-build-notifications.html#sample-build-notifications-ref | ||
*/ | ||
export class PhaseChangeEvent { | ||
/** | ||
* The triggering build's project name | ||
*/ | ||
public static get projectName() { | ||
return events.EventField.fromPath('$.detail.project-name'); | ||
} | ||
|
||
/** | ||
* The triggering build's id | ||
*/ | ||
public static get buildId() { | ||
return events.EventField.fromPath('$.detail.build-id'); | ||
} | ||
|
||
/** | ||
* The phase that was just completed | ||
*/ | ||
public static get completedPhase() { | ||
return events.EventField.fromPath('$.detail.completed-phase'); | ||
} | ||
|
||
/** | ||
* The status of the completed phase | ||
*/ | ||
public static get completedPhaseStatus() { | ||
return events.EventField.fromPath('$.detail.completed-phase-status'); | ||
} | ||
|
||
/** | ||
* The duration of the completed phase | ||
*/ | ||
public static get completedPhaseDurationSeconds() { | ||
return events.EventField.fromPath('$.detail.completed-phase-duration-seconds'); | ||
} | ||
|
||
/** | ||
* Whether the build is complete | ||
*/ | ||
public static get buildComplete() { | ||
return events.EventField.fromPath('$.detail.build-complete'); | ||
} | ||
|
||
private constructor() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.