Skip to content

feat(stepfunctions-tasks): allow EcsRunTask on fargate and ec2 to set capacity provider strategy#35465

Merged
mergify[bot] merged 43 commits intoaws:mainfrom
go-to-k:sfn-tasks-ecs-capacity
Jan 6, 2026
Merged

feat(stepfunctions-tasks): allow EcsRunTask on fargate and ec2 to set capacity provider strategy#35465
mergify[bot] merged 43 commits intoaws:mainfrom
go-to-k:sfn-tasks-ecs-capacity

Conversation

@go-to-k
Copy link
Copy Markdown
Contributor

@go-to-k go-to-k commented Sep 11, 2025

Issue # (if applicable)

Closes #20013 #30171 #7967

Reason for this change

The capacity provider strategy can't be set on EcsRunTask with EcsFargateLaunchTargetOptions and EcsEc2LaunchTargetOptions.

capacityProviderStrategy

The capacity provider strategy to use for the task.

If a capacityProviderStrategy is specified, the launchType parameter must be omitted. If no capacityProviderStrategy or launchType is specified, the defaultCapacityProviderStrategy for the cluster is used.

When you use cluster auto scaling, you must specify capacityProviderStrategy and not launchType.

A capacity provider strategy can contain a maximum of 20 capacity providers.

https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_RunTask.html

Description of changes

This PR adds a new property capacityProviderOptions (CapacityProviderOptions class with static factory methods as an union-like class) in the target options.

The CapacityProviderOptions has following sub types:

  • NoCapacityProviderOptions
  • CustomCapacityProviderOptions
  • DefaultCapacityProviderOptions

The NoCapacityProviderOptions creates the original settings with LaunchType (EC2 or FARGATE). It is a default value for the capacityProviderOptions.

The CustomCapacityProviderOptions allows users to set the capacity provider strategy without LaunchType.

The DefaultCapacityProviderOptions allows users to use the cluster's default capacity provider strategy. The default strategy can be set by specifying no options (LaunchType and CapacityProviderStrategy) in CFn.

Describe any new or updated permissions being added

Description of how you validated changes

Both unit tests and integ tests.

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 September 11, 2025 08:27
@github-actions github-actions bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 distinguished-contributor [Pilot] contributed 50+ PRs to the CDK labels Sep 11, 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)

@go-to-k go-to-k marked this pull request as ready for review September 11, 2025 12:35
@aws-cdk-automation aws-cdk-automation dismissed their stale review September 11, 2025 12:36

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

@@ -1,3 +1,3 @@
FROM public.ecr.aws/docker/library/python:3.12
FROM --platform=linux/amd64 public.ecr.aws/docker/library/python:3.12
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.

Because amd64 is used for cpu architecture in integ tests.

If this option is not specified, running the tests on Mac will result in an error during state machine execution.

@go-to-k go-to-k changed the title feat(stepfunctions-tasks): allow EcsRunTask on Fargate and EC2 to set capacity provider strategy feat(stepfunctions-tasks): allow EcsRunTask on fargate and ec2 to set capacity provider strategy Sep 11, 2025
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 11, 2025
@go-to-k go-to-k requested a review from ozelalisen December 30, 2025 01:38
Copy link
Copy Markdown
Contributor Author

@go-to-k go-to-k left a comment

Choose a reason for hiding this comment

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

@ozelalisen Thanks for your review!

I have fixed my code and replied to your comments.

@ozelalisen ozelalisen added the pr/needs-integration-tests-deployment Requires the PR to deploy the integration test snapshots. label Jan 5, 2026
@ozelalisen ozelalisen had a problem deploying to deployment-integ-test January 5, 2026 11:01 — with GitHub Actions Failure
@ozelalisen ozelalisen had a problem deploying to deployment-integ-test January 5, 2026 12:22 — with GitHub Actions Failure
@Abogical Abogical temporarily deployed to deployment-integ-test January 5, 2026 13:03 — with GitHub Actions Inactive
Copy link
Copy Markdown
Member

@ozelalisen ozelalisen left a comment

Choose a reason for hiding this comment

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

Have one minor comment

@ozelalisen ozelalisen removed the pr/needs-integration-tests-deployment Requires the PR to deploy the integration test snapshots. label Jan 5, 2026
@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 5, 2026
@mergify mergify bot dismissed ozelalisen’s stale review January 5, 2026 16:59

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 5, 2026
@go-to-k
Copy link
Copy Markdown
Contributor Author

go-to-k commented Jan 5, 2026

@ozelalisen

Applied the comment. I would appreciate it if you could look at it again.

@go-to-k go-to-k requested a review from ozelalisen January 5, 2026 18:01
Copy link
Copy Markdown
Member

@ozelalisen ozelalisen left a comment

Choose a reason for hiding this comment

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

Thanks for the fast iteration!

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jan 6, 2026

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 Jan 6, 2026

Merge Queue Status

✅ The pull request has been merged at 4623178

This pull request spent 55 minutes 36 seconds in the queue, including 31 minutes 13 seconds running CI.
The checks were run in-place.

Required conditions to merge

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 6, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jan 6, 2026

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 Jan 6, 2026

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 63ca2ae into aws:main Jan 6, 2026
21 of 24 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 6, 2026

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 Jan 6, 2026
@go-to-k go-to-k deleted the sfn-tasks-ecs-capacity branch January 6, 2026 18:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

distinguished-contributor [Pilot] contributed 50+ PRs to the CDK effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(stepfunctions-tasks): Allow specifying CapacityProviderStrategy in EcsRunTask

5 participants