-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
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.
packages/@aws-cdk/aws-ecs/lib/ec2/ec2-task-event-rule-target.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-ecs/lib/ec2/ec2-task-event-rule-target.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-ecs/README.md
Outdated
### Integration with CloudWatch Events | ||
|
||
To start an ECS task on an EC2-backed Cluster, instantiate an | ||
`Ec2TaskEventRuleTarget` intead of an `Ec2Service`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intead => instead
// Pass an environment variable to the container 'TheContainer' in the task | ||
rule.addTarget(target, { | ||
jsonTemplate: JSON.stringify({ | ||
containerOverrides: [{ |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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', { |
There was a problem hiding this comment.
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.
There was a problem hiding this 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?
packages/@aws-cdk/aws-ecs/lib/ec2/ec2-task-event-rule-target.ts
Outdated
Show resolved
Hide resolved
Not via CFN. |
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.
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.