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