Skip to content

Conversation

go-to-k
Copy link
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](https://docs.aws.amazon.com/ja_jp/AmazonECS/latest/APIReference/API_RunTask.html#API_RunTask_RequestSyntax)
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/ja_jp/AmazonECS/latest/APIReference/API_RunTask.html

Description of changes

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

The CapacityProviderOptionsBase 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
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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. p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(stepfunctions-tasks): Allow specifying CapacityProviderStrategy in EcsRunTask
2 participants