Class AsgCapacityProviderProps
The options for creating an Auto Scaling Group Capacity Provider.
Inheritance
Namespace: Amazon.CDK.AWS.ECS
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class AsgCapacityProviderProps : Object, IAsgCapacityProviderProps, IAddAutoScalingGroupCapacityOptions
Syntax (vb)
Public Class AsgCapacityProviderProps
Inherits Object
Implements IAsgCapacityProviderProps, IAddAutoScalingGroupCapacityOptions
Remarks
ExampleMetadata: infused
Examples
Vpc vpc;
var launchTemplate = new LaunchTemplate(this, "ASG-LaunchTemplate", new LaunchTemplateProps {
InstanceType = new InstanceType("t3.medium"),
MachineImage = EcsOptimizedImage.AmazonLinux2(),
UserData = UserData.ForLinux()
});
var autoScalingGroup = new AutoScalingGroup(this, "ASG", new AutoScalingGroupProps {
Vpc = vpc,
MixedInstancesPolicy = new MixedInstancesPolicy {
InstancesDistribution = new InstancesDistribution {
OnDemandPercentageAboveBaseCapacity = 50
},
LaunchTemplate = launchTemplate
}
});
var cluster = new Cluster(this, "Cluster", new ClusterProps { Vpc = vpc });
var capacityProvider = new AsgCapacityProvider(this, "AsgCapacityProvider", new AsgCapacityProviderProps {
AutoScalingGroup = autoScalingGroup,
MachineImageType = MachineImageType.AMAZON_LINUX_2
});
cluster.AddAsgCapacityProvider(capacityProvider);
Synopsis
Constructors
AsgCapacityProviderProps() |
Properties
AutoScalingGroup | The autoscaling group to add as a Capacity Provider. |
CanContainersAccessInstanceRole | Specifies whether the containers can access the container instance role. |
CapacityProviderName | The name of the capacity provider. |
EnableManagedDraining | Managed instance draining facilitates graceful termination of Amazon ECS instances. |
EnableManagedScaling | When enabled the scale-in and scale-out actions of the cluster's Auto Scaling Group will be managed for you. |
EnableManagedTerminationProtection | When enabled the Auto Scaling Group will only terminate EC2 instances that no longer have running non-daemon tasks. |
InstanceWarmupPeriod | The period of time, in seconds, after a newly launched Amazon EC2 instance can contribute to CloudWatch metrics for Auto Scaling group. |
MachineImageType | What type of machine image this is. |
MaximumScalingStepSize | Maximum scaling step size. |
MinimumScalingStepSize | Minimum scaling step size. |
SpotInstanceDraining | Specify whether to enable Automated Draining for Spot Instances running Amazon ECS Services. |
TargetCapacityPercent | Target capacity percent. |
TopicEncryptionKey | If |
Constructors
AsgCapacityProviderProps()
public AsgCapacityProviderProps()
Properties
AutoScalingGroup
The autoscaling group to add as a Capacity Provider.
public IAutoScalingGroup AutoScalingGroup { get; set; }
Property Value
CanContainersAccessInstanceRole
Specifies whether the containers can access the container instance role.
public Nullable<bool> CanContainersAccessInstanceRole { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: false
CapacityProviderName
The name of the capacity provider.
public string CapacityProviderName { get; set; }
Property Value
System.String
Remarks
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-
.
Default: CloudFormation-generated name
EnableManagedDraining
Managed instance draining facilitates graceful termination of Amazon ECS instances.
public Nullable<bool> EnableManagedDraining { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
This allows your service workloads to stop safely and be rescheduled to non-terminating instances. Infrastructure maintenance and updates are preformed without disruptions to workloads. To use managed instance draining, set enableManagedDraining to true.
Default: true
EnableManagedScaling
When enabled the scale-in and scale-out actions of the cluster's Auto Scaling Group will be managed for you.
public Nullable<bool> EnableManagedScaling { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
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.
Default: true
EnableManagedTerminationProtection
When enabled the Auto Scaling Group will only terminate EC2 instances that no longer have running non-daemon tasks.
public Nullable<bool> EnableManagedTerminationProtection { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
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.
Default: true
InstanceWarmupPeriod
The period of time, in seconds, after a newly launched Amazon EC2 instance can contribute to CloudWatch metrics for Auto Scaling group.
public Nullable<double> InstanceWarmupPeriod { get; set; }
Property Value
System.Nullable<System.Double>
Remarks
Must be between 0 and 10000.
Default: 300
MachineImageType
What type of machine image this is.
public Nullable<MachineImageType> MachineImageType { get; set; }
Property Value
System.Nullable<MachineImageType>
Remarks
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.
Default: - Automatically determined from machineImage
, if available, otherwise MachineImageType.AMAZON_LINUX_2
.
MaximumScalingStepSize
Maximum scaling step size.
public Nullable<double> MaximumScalingStepSize { get; set; }
Property Value
System.Nullable<System.Double>
Remarks
In most cases this should be left alone.
Default: 1000
MinimumScalingStepSize
Minimum scaling step size.
public Nullable<double> MinimumScalingStepSize { get; set; }
Property Value
System.Nullable<System.Double>
Remarks
In most cases this should be left alone.
Default: 1
SpotInstanceDraining
Specify whether to enable Automated Draining for Spot Instances running Amazon ECS Services.
public Nullable<bool> SpotInstanceDraining { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
For more information, see Using Spot Instances.
Default: false
TargetCapacityPercent
Target capacity percent.
public Nullable<double> TargetCapacityPercent { get; set; }
Property Value
System.Nullable<System.Double>
Remarks
In most cases this should be left alone.
Default: 100
TopicEncryptionKey
If AddAutoScalingGroupCapacityOptions.taskDrainTime
is non-zero, then the ECS cluster creates an SNS Topic to as part of a system to drain instances of tasks when the instance is being shut down. If this property is provided, then this key will be used to encrypt the contents of that SNS Topic. See SNS Data Encryption for more information.
public IKey TopicEncryptionKey { get; set; }
Property Value
Remarks
Default: The SNS Topic will not be encrypted.