AsgCapacityProviderProps Struct
The options for creating an Auto Scaling Group Capacity Provider.
Example
declare const vpc: ec2.Vpc;
const launchTemplate = new ec2.LaunchTemplate(this, 'ASG-LaunchTemplate', {
instanceType: new ec2.InstanceType('t3.medium'),
machineImage: ecs.EcsOptimizedImage.amazonLinux2(),
userData: ec2.UserData.forLinux(),
});
const autoScalingGroup = new autoscaling.AutoScalingGroup(this, 'ASG', {
vpc,
mixedInstancesPolicy: {
instancesDistribution: {
onDemandPercentageAboveBaseCapacity: 50,
},
launchTemplate: launchTemplate,
},
});
const cluster = new ecs.Cluster(this, 'Cluster', { vpc });
const capacityProvider = new ecs.AsgCapacityProvider(this, 'AsgCapacityProvider', {
autoScalingGroup,
machineImageType: ecs.MachineImageType.AMAZON_LINUX_2,
});
cluster.addAsgCapacityProvider(capacityProvider);
Properties
autoScalingGroupIAutoScalingGroupauto_scaling_groupIAutoScalingGroupautoScalingGroupIAutoScalingGroupAutoScalingGroupIAutoScalingGroupAutoScalingGroupIAutoScalingGrouprequired#notes
Warning: When passing an imported resource using AutoScalingGroup.fromAutoScalingGroupName along with enableManagedTerminationProtection: true, the AsgCapacityProvider construct will not be able to enforce the option newInstancesProtectedFromScaleIn of the AutoScalingGroup. In this case the constructor of AsgCapacityProvider will throw an exception.
capacityProviderNameoptionalstringcapacity_provider_nameoptionalstrcapacityProviderNameoptionalStringCapacityProviderNameoptionalstringCapacityProviderNameoptional*string#Default: CloudFormation-generated name
notes
If a name is specified, it cannot start with aws, ecs, or fargate. If no name is specified, a default name in the CFNStackName-CFNResourceName-RandomString format is used. If the stack name starts with aws, ecs, or fargate, a unique resource name is generated that starts with cp-.
enableManagedDrainingoptionalbooleanenable_managed_drainingoptionalboolenableManagedDrainingoptionalBooleanEnableManagedDrainingoptionalboolEnableManagedDrainingoptional*bool#Default: CloudFormation implicitly enables managed draining when not specified.
notes
This allows your service workloads to stop safely and be rescheduled to non-terminating instances. Infrastructure maintenance and updates are performed without disruptions to workloads.
When undefined (recommended), CloudFormation will implicitly enable managed draining. Set to true for explicit enablement or false to explicitly disable this feature.
enableManagedScalingoptionalbooleanenable_managed_scalingoptionalboolenableManagedScalingoptionalBooleanEnableManagedScalingoptionalboolEnableManagedScalingoptional*bool= true#notes
This means your cluster will automatically scale instances based on the load your tasks put on the cluster. For more information, see Using Managed Scaling in the ECS Developer Guide.
enableManagedTerminationProtectionoptionalbooleanenable_managed_termination_protectionoptionalboolenableManagedTerminationProtectionoptionalBooleanEnableManagedTerminationProtectionoptionalboolEnableManagedTerminationProtectionoptional*bool= true#notes
Scale-in protection will be automatically enabled on instances. When all non-daemon tasks are stopped on an instance, ECS initiates the scale-in process and turns off scale-in protection for the instance. The Auto Scaling Group can then terminate the instance. For more information see Managed termination protection in the ECS Developer Guide.
Managed scaling must also be enabled.
instanceWarmupPeriodoptionalnumberinstance_warmup_periodoptionalint | floatinstanceWarmupPeriodoptionalNumberInstanceWarmupPeriodoptionaldoubleInstanceWarmupPeriodoptional*float64= 300#Must be between 0 and 10000.
machineImageTypeoptionalMachineImageTypemachine_image_typeoptionalMachineImageTypemachineImageTypeoptionalMachineImageTypeMachineImageTypeoptionalMachineImageTypeMachineImageTypeoptionalMachineImageType#Default: Automatically determined from machineImage, if available, otherwise MachineImageType.AMAZON_LINUX_2.
notes
Depending on the setting, different UserData will automatically be added to the AutoScalingGroup to configure it properly for use with ECS.
If you create an AutoScalingGroup yourself and are adding it via addAutoScalingGroup(), you must specify this value. If you are adding an autoScalingGroup via addCapacity, this value will be determined from the machineImage you pass.
maximumScalingStepSizeoptionalnumbermaximum_scaling_step_sizeoptionalint | floatmaximumScalingStepSizeoptionalNumberMaximumScalingStepSizeoptionaldoubleMaximumScalingStepSizeoptional*float64= 1000#In most cases this should be left alone.
minimumScalingStepSizeoptionalnumberminimum_scaling_step_sizeoptionalint | floatminimumScalingStepSizeoptionalNumberMinimumScalingStepSizeoptionaldoubleMinimumScalingStepSizeoptional*float64= 1#In most cases this should be left alone.
spotInstanceDrainingoptionalbooleanspot_instance_drainingoptionalboolspotInstanceDrainingoptionalBooleanSpotInstanceDrainingoptionalboolSpotInstanceDrainingoptional*bool= false#For more information, see Using Spot Instances.
targetCapacityPercentoptionalnumbertarget_capacity_percentoptionalint | floattargetCapacityPercentoptionalNumberTargetCapacityPercentoptionaldoubleTargetCapacityPercentoptional*float64= 100#In most cases this should be left alone.
topicEncryptionKeyoptionalIKeytopic_encryption_keyoptionalIKeytopicEncryptionKeyoptionalIKeyTopicEncryptionKeyoptionalIKeyTopicEncryptionKeyoptionalIKey#Default: The SNS Topic will not be encrypted.