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(aws-ecs): add support for Event Targets #1571

Merged
merged 4 commits into from
Feb 4, 2019
Merged

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Jan 18, 2019

EC2 task definitions can now be used as CloudWatch event targets.

Fixes #1370.

ALSO IN THIS COMMIT

Note: Unit tests still missing, but the integ test works. Yay!

Fargate support is not in CloudFormation, that's why.


Pull Request Checklist

  • Testing
    • Unit test added
    • CLI change?: manually run integration tests and paste output as a PR comment
    • cdk-init template change?: coordinated update of integration tests with team
  • Docs
    • jsdocs: All public APIs documented
    • README: README and/or documentation topic updated
  • Title and Description
    • Change type: title prefixed with fix, feat 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.

EC2 task definitions can now be used as CloudWatch event targets.

ALSO IN THIS COMMIT

* Improve hash calculation of Docker images.
* Add `grantPassRole()` method to iam.Role

Fixes #1370.
@rix0rrr rix0rrr requested review from SoManyHs and a team as code owners January 18, 2019 17:27
@sam-goodwin sam-goodwin added feature-request A feature should be added or improved. @aws-cdk/aws-ecs Related to Amazon Elastic Container @aws-cdk/aws-events Related to CloudWatch Events labels Jan 18, 2019
### Integration with CloudWatch Events

To start an ECS task on an EC2-backed Cluster, instantiate an
`Ec2TaskEventRuleTarget` intead of an `Ec2Service`:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intead => instead

packages/@aws-cdk/aws-ecs/test/ec2/integ.event-task.lit.ts Outdated Show resolved Hide resolved
// Pass an environment variable to the container 'TheContainer' in the task
rule.addTarget(target, {
jsonTemplate: JSON.stringify({
containerOverrides: [{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't it make sense to make this a feature of Ec2TaskEventRuleTarget?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mayhaps, but I don't think that's how the API works out.

Or does the target have a way of mixing into the inputTemplate?

});

// Use Ec2TaskEventRuleTarget as the target of the EventRule
const target = new ecs.Ec2TaskEventRuleTarget(stack, 'EventTarget', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if our CWE pattern should change to always require an "integration" type like this. Seems like the current model is too naive.

@sam-goodwin sam-goodwin removed the feature-request A feature should be added or improved. label Jan 22, 2019
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there support for fargate tasks as targets?

@rix0rrr
Copy link
Contributor Author

rix0rrr commented Feb 4, 2019

Isn't there support for fargate tasks as targets?

Not via CFN.

@rix0rrr rix0rrr merged commit aa68db5 into master Feb 4, 2019
@rix0rrr rix0rrr deleted the huijbers/ecs-cwe branch February 4, 2019 11:03
moofish32 pushed a commit to moofish32/aws-cdk that referenced this pull request Feb 5, 2019
EC2 task definitions can now be used as CloudWatch event targets.

ALSO IN THIS COMMIT

* Improve hash calculation of Docker images.
* Add `grantPassRole()` method to iam.Role

Fixes aws#1370.
@NGL321 NGL321 added the contribution/core This is a PR that came from AWS. label Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container @aws-cdk/aws-events Related to CloudWatch Events contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ECS: implement IEventRuleTarget iam: add Role.grantPassRole() helper
4 participants