EcsFargateLaunchTargetOptions Struct
Properties to define an ECS service.
Example
ts
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(),
}),
});
Properties
capacityProviderOptionsCapacityProviderOptionscapacity_provider_optionsCapacityProviderOptionscapacityProviderOptionsCapacityProviderOptionsCapacityProviderOptionsCapacityProviderOptionsCapacityProviderOptionsCapacityProviderOptions= 'FARGATE' LaunchType running tas…#The capacity provider options to use for the task.
notes · default
This property allows you to set the capacity provider strategy for the task.
If you want to set the capacity provider strategy for the task, specify CapacityProviderOptions.custom(). This is required to use the FARGATE_SPOT capacity provider.
If you want to use the cluster's default capacity provider strategy, specify CapacityProviderOptions.default().
Default: 'FARGATE' LaunchType running tasks on AWS Fargate On-Demand infrastructure is used without the capacity provider strategy.
platformVersionFargatePlatformVersionplatform_versionFargatePlatformVersionplatformVersionFargatePlatformVersionPlatformVersionFargatePlatformVersionPlatformVersionFargatePlatformVersionrequired#Refers to a specific runtime environment for Fargate task infrastructure.
Fargate platform version is a combination of the kernel and container runtime versions.