aws_stepfunctions_tasks: cannot add capacity provider when using EcsEc2LaunchTarget
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
The example code provided in https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_stepfunctions_tasks/EcsEc2LaunchTarget.html is not functional. Although adding a default asg capacity provider works in the console, doing it in cdk returns an error if the capacity provider is not specified in the EcsRunTask parameters. I currently cannot find any way to add the capacity provider to the parameters.
### Expected Behavior
My state machine to successfully execute an aws_stepfunctions_tasks.EcsRunTask with the EcsEc2LaunchTarget when I have defined a default capacity provider strategy for my cluster.
### Current Behavior
The task receives an error from the cluster and cannot be started.
```
"cause": "No Container Instances were found in your cluster. (Service: AmazonECS; Status Code: 400; Error Code: InvalidParameterException; Request ID: cb76661d-7bb1-49ee-8fa7-8ba1feea5656; Proxy: null)",
"error": "ECS.InvalidParameterException",
"resource": "runTask.waitForTaskToken",
"resourceType": "ecs"
```
### Reproduction Steps
```
cluster = ecs.Cluster(self, "Cluster", vpc=default_vpc.vpc)
capacity_provider = ecs.AsgCapacityProvider(
self,
"CapacityProvider",
auto_scaling_group=autoscaling_group,
spot_instance_draining=True,
)
cluster.add_asg_capacity_provider(capacity_provider, spot_instance_draining=True)
cluster.add_default_capacity_provider_strategy(
[
ecs.CapacityProviderStrategy(
capacity_provider=capacity_provider.capacity_provider_name,
base=10,
weight=100,
),
]
)
run_task = sfn_tasks.EcsRunTask(
self,
task.title().replace("_", ""),
cluster=cluster,
launch_target=sfn_tasks.EcsEc2LaunchTarget(),
task_definition=task_definition,
container_overrides=[
sfn_tasks.ContainerOverride(
container_definition=task_definition.default_container,
command=sfn.JsonPath.list_at(f"$.{command}"),
environment=env,
)
],
propagated_tag_source=PropagatedTagSource.TASK_DEFINITION,
result_path=result_path,
integration_pattern=sfn.IntegrationPattern.WAIT_FOR_TASK_TOKEN,
heartbeat_timeout=sfn.Timeout.duration(cdk.Duration.seconds(HEARTBEAT_TIMEOUT)),
task_timeout=sfn.Timeout.duration(cdk.Duration.minutes(120)),
).add_retry(
errors=[
"States.HeartbeatTimeout",
"States.Timeout",
"Ecs.ClientException",
"Ecs.SdkClientException",
"Ecs.ServerException",
],
interval=cdk.Duration.seconds(30),
jitter_strategy=sfn.JitterType.FULL,
)
```
### Possible Solution
It would be helpful if it could be passed to the launch target in the same manner as placement constraints and placement strategies.
### Additional Information/Context
_No response_
### CDK CLI Version
cdk@2.110.1
### Framework Version
_No response_
### Node.js Version
18
### OS
ubuntu-latest
### Language
Python
### Language Version
3.11
### Other information
_No response_
Contributor guide
Research direction
Start with the EcsEc2LaunchTarget API entry and EcsRunTask launch_target handling described in the issue, then reproduce the Python example with the default ECS capacity-provider strategy. Done when the generated Step Functions ECS task request carries the cluster's capacity-provider strategy and starts successfully; add or update the relevant regression test if the repository exposes one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python, typescript
- Domain
- cloud, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100