Skip to content

feat(ecs): automatically create ec2InstanceProfile for ManagedInstancesCapacityProvider#35796

Merged
mergify[bot] merged 13 commits intoaws:mainfrom
aemada-aws:auto-create-profile
Dec 22, 2025
Merged

feat(ecs): automatically create ec2InstanceProfile for ManagedInstancesCapacityProvider#35796
mergify[bot] merged 13 commits intoaws:mainfrom
aemada-aws:auto-create-profile

Conversation

@aemada-aws
Copy link
Copy Markdown
Contributor

@aemada-aws aemada-aws commented Oct 21, 2025

Issue # (if applicable)

Related to #35742

Reason for this change

The ManagedInstancesCapacityProvider construct was requiring users to pass ec2InstanceProfile. This PR makes this optional and automatically creates one.

Note that the role name must be prefixed with "ecsInstanceRole". This is a restriction from the managed policy on the infrastructure role https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonECSInfrastructureRolePolicyForManagedInstances.html
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/managed-instances-instance-profile.html

Description of changes

ec2InstanceProfile is now optional

Describe any new or updated permissions being added

  • A default role is created with a scoped down version of AmazonECSInstanceRolePolicyForManagedInstances - AWS managed policy attached to the EC2 instance profile role that provides necessary permissions for ECS managed instances to register with ecs clusters, pull from ECR, send logs to CW and access ECS agent endpoint.

Description of how you validated changes

Checklist


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

@aws-cdk-automation aws-cdk-automation requested a review from a team October 21, 2025 12:29
@github-actions github-actions bot added the p2 label Oct 21, 2025
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Oct 21, 2025
Copy link
Copy Markdown
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

(This review is outdated)

@aws-cdk-automation aws-cdk-automation dismissed their stale review October 21, 2025 12:55

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aemada-aws aemada-aws force-pushed the auto-create-profile branch 3 times, most recently from bdcd023 to b14b39c Compare October 21, 2025 13:19
@github-actions github-actions bot added bug This issue is a bug. effort/medium Medium work item – several days of effort labels Oct 21, 2025
Copy link
Copy Markdown
Contributor

@kg-aws kg-aws left a comment

Choose a reason for hiding this comment

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

Thank you!

@aws-cdk-automation aws-cdk-automation added the pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes. label Oct 27, 2025
@aemada-aws aemada-aws force-pushed the auto-create-profile branch 2 times, most recently from b6abb9a to 786bc73 Compare October 30, 2025 13:06
@gael-ft
Copy link
Copy Markdown

gael-ft commented Oct 31, 2025

Correct me if I'm wrong, but as long as this._hasEc2Capacity = true; link is not set when adding a ManagedInstancesCapacityProvider link, then the issue #35742 is not fixed.

This is due to the fact that, Ec2Service validatation link

@isker
Copy link
Copy Markdown
Contributor

isker commented Oct 31, 2025

You're correct that it still doesn't work with Ec2Service, which is why they are changing all the examples to use FargateService.

@gael-ft
Copy link
Copy Markdown

gael-ft commented Nov 1, 2025

Ah ok missed that info sorry ...

It raise some questions about some Ec2Service feature such as daemon services.
I'll asked them directly on the main issue

@kg-aws
Copy link
Copy Markdown
Contributor

kg-aws commented Nov 3, 2025

Thank you @gael-ft. Would you mind creating a new feature request for the daemon service use case with ECS Managed Instances through a dedicated GitHub issue?

@isker
Copy link
Copy Markdown
Contributor

isker commented Nov 10, 2025

@aemada-aws what’s blocking this from being merged?

@Abogical
Copy link
Copy Markdown
Member

@isker Not sure if you noticed, but we were waiting for your response to this question: #35796 (comment)

@isker
Copy link
Copy Markdown
Contributor

isker commented Nov 18, 2025

I don't know the answer to that question. I didn't write this PR.

@Abogical
Copy link
Copy Markdown
Member

@isker Oh sorry, I misread the author. @aemada-aws can you answer the question for reference?

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 16, 2025

⚠️ Experimental Feature: This security report is currently in experimental phase. Results may include false positives and the rules are being actively refined.
Please try merge from main to avoid findings unrelated to the PR.


TestsPassed ✅SkippedFailed
Security Guardian Results50 ran50 passed
TestResult
No test annotations available

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 16, 2025

⚠️ Experimental Feature: This security report is currently in experimental phase. Results may include false positives and the rules are being actively refined.
Please try merge from main to avoid findings unrelated to the PR.


TestsPassed ✅SkippedFailed
Security Guardian Results with resolved templates50 ran50 passed
TestResult
No test annotations available

@aemada-aws aemada-aws requested a review from gasolima December 16, 2025 17:45
@aemada-aws aemada-aws added the pr/needs-integration-tests-deployment Requires the PR to deploy the integration test snapshots. label Dec 17, 2025
@aemada-aws aemada-aws had a problem deploying to deployment-integ-test December 17, 2025 10:59 — with GitHub Actions Failure
@aemada-aws aemada-aws added the pr/do-not-merge This PR should not be merged at this time. label Dec 17, 2025
@aemada-aws
Copy link
Copy Markdown
Contributor Author

Integ test is failing because deletion fails because of a separate issue: #36071

@aemada-aws
Copy link
Copy Markdown
Contributor Author

Correct me if I'm wrong, but as long as this._hasEc2Capacity = true; link is not set when adding a ManagedInstancesCapacityProvider link, then the issue #35742 is not fixed.

This is due to the fact that, Ec2Service validatation link

you are correct, this doesn't fix the issue of using the managed capacity provider with the ec2service construct.

@aemada-aws aemada-aws requested a review from gasolima December 17, 2025 16:40
@aemada-aws aemada-aws removed pr/do-not-merge This PR should not be merged at this time. pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes. pr/needs-integration-tests-deployment Requires the PR to deploy the integration test snapshots. labels Dec 22, 2025
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 22, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 22, 2025

Merge Queue Status

🚫 The pull request has left the queue (rule: default-squash) at b1e1db9

This pull request spent 4 seconds in the queue, with no time running CI.

Reason

The pull request can't be updated

For security reasons, Mergify can't update this pull request. Try updating locally.
GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/security-report.yml without workflows permission

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio requeue comment.

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 22, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 9218ea8 into aws:main Dec 22, 2025
22 of 23 checks passed
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 22, 2025

Merge Queue Status

✅ The pull request has been merged at 0e880e8

This pull request spent 5 seconds in the queue, with no time running CI.
The checks were run in-place.

Required conditions to merge

@github-actions
Copy link
Copy Markdown
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/medium Medium work item – several days of effort p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants