class CapacityProviderOptions
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.StepFunctions.Tasks.CapacityProviderOptions |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsstepfunctionstasks#CapacityProviderOptions |
Java | software.amazon.awscdk.services.stepfunctions.tasks.CapacityProviderOptions |
Python | aws_cdk.aws_stepfunctions_tasks.CapacityProviderOptions |
TypeScript (source) | aws-cdk-lib » aws_stepfunctions_tasks » CapacityProviderOptions |
Capacity provider options.
Example
const vpc = ec2.Vpc.fromLookup(this, 'Vpc', {
isDefault: true,
});
const cluster = new ecs.Cluster(this, 'FargateCluster', { vpc });
const taskDefinition = new ecs.TaskDefinition(this, 'TD', {
memoryMiB: '512',
cpu: '256',
compatibility: ecs.Compatibility.FARGATE,
});
// Use custom() option - specify custom capacity provider strategy
const runTaskWithCustom = new tasks.EcsRunTask(this, 'RunTaskWithCustom', {
cluster,
taskDefinition,
launchTarget: new tasks.EcsFargateLaunchTarget({
platformVersion: ecs.FargatePlatformVersion.VERSION1_4,
capacityProviderOptions: tasks.CapacityProviderOptions.custom([
{ capacityProvider: 'FARGATE_SPOT', weight: 2, base: 1 },
{ capacityProvider: 'FARGATE', weight: 1 },
]),
}),
});
// Use default() option - uses cluster's default capacity provider strategy
const runTaskWithDefault = new tasks.EcsRunTask(this, 'RunTaskWithDefault', {
cluster,
taskDefinition,
launchTarget: new tasks.EcsFargateLaunchTarget({
platformVersion: ecs.FargatePlatformVersion.VERSION1_4,
capacityProviderOptions: tasks.CapacityProviderOptions.default(),
}),
});
Methods
| Name | Description |
|---|---|
| static custom(capacityProviderStrategy) | Use a custom capacity provider strategy. |
| static default() | Use the cluster's default capacity provider strategy. |
static custom(capacityProviderStrategy)
public static custom(capacityProviderStrategy: CapacityProviderStrategy[]): CapacityProviderOptions
Parameters
- capacityProviderStrategy
CapacityProvider Strategy []— The capacity provider strategy to use for the task.
Returns
Use a custom capacity provider strategy.
You can specify between 1 and 20 capacity providers.
static default()
public static default(): CapacityProviderOptions
Returns
Use the cluster's default capacity provider strategy.

.NET
Go
Java
Python
TypeScript (