Skip to content

feat(aws-ecs): add support for Event Targets - #1571

Merged
rix0rrr merged 4 commits into
masterfrom
huijbers/ecs-cwe
Feb 4, 2019
Merged

rix0rrr merged 4 commits into
masterfrom
huijbers/ecs-cwe

Conversation

@rix0rrr

@rix0rrr rix0rrr commented Jan 18, 2019 •

Copy link
Copy Markdown
Contributor

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 a team and SoManyHs 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
Comment thread packages/aws-cdk/lib/docker.ts Resolved
Comment thread 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`:

Copy link
Copy Markdown
Contributor

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: [{

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@eladb eladb left a comment

Copy link
Copy Markdown
Contributor

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

rix0rrr commented Feb 4, 2019

Copy link
Copy Markdown
Contributor Author

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