Repository navigation
feat(aws-ecs): add support for Event Targets - #1571
Merged
Merged
Conversation
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.
sam-goodwin
reviewed
Jan 18, 2019
eladb
reviewed
Jan 20, 2019
| ### Integration with CloudWatch Events | ||
|
|
||
| To start an ECS task on an EC2-backed Cluster, instantiate an | ||
| `Ec2TaskEventRuleTarget` intead of an `Ec2Service`: |
| // Pass an environment variable to the container 'TheContainer' in the task | ||
| rule.addTarget(target, { | ||
| jsonTemplate: JSON.stringify({ | ||
| containerOverrides: [{ |
Contributor
There was a problem hiding this comment.
Doesn't it make sense to make this a feature of Ec2TaskEventRuleTarget?
Contributor
Author
There was a problem hiding this comment.
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', { |
Contributor
There was a problem hiding this comment.
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.
eladb
approved these changes
Feb 4, 2019
eladb
left a comment
Contributor
There was a problem hiding this comment.
Isn't there support for fargate tasks as targets?
Contributor
Author
Not via CFN. |
eladb
approved these changes
Feb 4, 2019
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.
ali-n4i
pushed a commit
to ali-n4i/aws-cdk
that referenced
this pull request
Jul 29, 2026
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.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EC2 task definitions can now be used as CloudWatch event targets.
Fixes #1370.
ALSO IN THIS COMMIT
grantPassRole()method to iam.Role. Fixes iam: add Role.grantPassRole() helper #322.Note: Unit tests still missing, but the integ test works. Yay!
Fargate support is not in CloudFormation, that's why.
Pull Request Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.