Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(events): better modeling of CW Event Targets #2576

Merged
merged 37 commits into from
May 20, 2019
Merged

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented May 17, 2019

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().

Pull Request Checklist

  • Testing
    • Unit test added (prefer not to modify an existing test, otherwise, it's probably a breaking change)
    • CLI change?: coordinate update of integration tests with team
    • cdk-init template change?: coordinated update of integration tests with team
  • Docs
    • jsdocs: All public APIs documented
    • README: README and/or documentation topic updated
    • Design: For significant features, design document added to design folder
  • Title and Description
    • Change type: title prefixed with fix, feat and module name in parens, which will appear in changelog
    • Title: use lower-case and doesn't end with a period
    • Breaking?: last paragraph: "BREAKING CHANGE: <describe what changed + link for details>"
    • Issues: Indicate issues fixed via: "Fixes #xxx" or "Closes #xxx"
  • Sensitive Modules (requires 2 PR approvers)
    • IAM Policy Document (in @aws-cdk/aws-iam)
    • EC2 Security Groups and ACLs (in @aws-cdk/aws-ec2)
    • Grant APIs (only if not based on official documentation with a reference)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.

rix0rrr added 30 commits May 8, 2019 15:50
WE used to have this because we couldn't validate what tokens
returned previously, but now that we have PostProcessingToken we can!
@rix0rrr rix0rrr self-assigned this May 20, 2019
@rix0rrr rix0rrr merged commit 7cb8e5e into master May 20, 2019
@rix0rrr rix0rrr deleted the huijbers/ecs-events branch May 20, 2019 15:08
@NGL321 NGL321 added the contribution/core This is a PR that came from AWS. label Sep 27, 2019
This was referenced Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
3 participants