Class AsgCapacityProviderProps
The options for creating an Auto Scaling Group Capacity Provider.
Inheritance
Namespace: Amazon.CDK.AWS.ECS
Assembly: Amazon.CDK.AWS.ECS.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 cluster = new Cluster(this, "Cluster", new ClusterProps {
Vpc = vpc
});
var autoScalingGroup = new AutoScalingGroup(this, "ASG", new AutoScalingGroupProps {
Vpc = vpc,
InstanceType = new InstanceType("t2.micro"),
MachineImage = EcsOptimizedImage.AmazonLinux2(),
MinCapacity = 0,
MaxCapacity = 100
});
var capacityProvider = new AsgCapacityProvider(this, "AsgCapacityProvider", new AsgCapacityProviderProps {
AutoScalingGroup = autoScalingGroup
});
cluster.AddAsgCapacityProvider(capacityProvider);
var taskDefinition = new Ec2TaskDefinition(this, "TaskDef");
taskDefinition.AddContainer("web", new ContainerDefinitionOptions {
Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample"),
MemoryReservationMiB = 256
});
new Ec2Service(this, "EC2Service", new Ec2ServiceProps {
Cluster = cluster,
TaskDefinition = taskDefinition,
CapacityProviderStrategies = new [] { new CapacityProviderStrategy {
CapacityProvider = capacityProvider.CapacityProviderName,
Weight = 1
} }
});
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. |
EnableManagedScaling | Whether to enable managed scaling. |
EnableManagedTerminationProtection | Whether to enable managed termination protection. |
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. |
TaskDrainTime | (deprecated) The time period to wait before force terminating an instance that is draining. |
TopicEncryptionKey | If {@link 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. |
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.
Default: CloudFormation-generated name
EnableManagedScaling
Whether to enable managed scaling.
public Nullable<bool> EnableManagedScaling { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: true
EnableManagedTerminationProtection
Whether to enable managed termination protection.
public Nullable<bool> EnableManagedTerminationProtection { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: true
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
TaskDrainTime
(deprecated) The time period to wait before force terminating an instance that is draining.
public Duration TaskDrainTime { get; set; }
Property Value
Remarks
This creates a Lambda function that is used by a lifecycle hook for the AutoScalingGroup that will delay instance termination until all ECS tasks have drained from the instance. Set to 0 to disable task draining.
Set to 0 to disable task draining.
Default: Duration.minutes(5)
Stability: Deprecated
TopicEncryptionKey
If {@link 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.