Interface IAddCapacityOptions
The properties for adding instance capacity to an AutoScalingGroup.
Inherited Members
Namespace: Amazon.CDK.AWS.ECS
Assembly: Amazon.CDK.AWS.ECS.dll
Syntax (csharp)
public interface IAddCapacityOptions : IAddAutoScalingGroupCapacityOptions, ICommonAutoScalingGroupProps
Syntax (vb)
Public Interface IAddCapacityOptions
Inherits IAddAutoScalingGroupCapacityOptions, ICommonAutoScalingGroupProps
Remarks
ExampleMetadata: infused
Examples
Vpc vpc;
// Create an ECS cluster
var cluster = new Cluster(this, "Cluster", new ClusterProps {
Vpc = vpc
});
// Add capacity to it
cluster.AddCapacity("DefaultAutoScalingGroupCapacity", new AddCapacityOptions {
InstanceType = new InstanceType("t2.xlarge"),
DesiredCapacity = 3
});
var taskDefinition = new Ec2TaskDefinition(this, "TaskDef");
taskDefinition.AddContainer("DefaultContainer", new ContainerDefinitionOptions {
Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample"),
MemoryLimitMiB = 512
});
// Instantiate an Amazon ECS Service
var ecsService = new Ec2Service(this, "Service", new Ec2ServiceProps {
Cluster = cluster,
TaskDefinition = taskDefinition
});
Synopsis
Properties
InstanceType | The EC2 instance type to use when launching instances into the AutoScalingGroup. |
MachineImage | The ECS-optimized AMI variant to use. |
Properties
InstanceType
The EC2 instance type to use when launching instances into the AutoScalingGroup.
InstanceType InstanceType { get; }
Property Value
MachineImage
The ECS-optimized AMI variant to use.
virtual IMachineImage MachineImage { get; }
Property Value
Remarks
The default is to use an ECS-optimized AMI of Amazon Linux 2 which is automatically updated to the latest version on every deployment. This will replace the instances in the AutoScalingGroup. Make sure you have not disabled task draining, to avoid downtime when the AMI updates.
To use an image that does not update on every deployment, pass:
var machineImage = EcsOptimizedImage.AmazonLinux2(AmiHardwareType.STANDARD, new EcsOptimizedImageOptions {
CachedInContext = true
});
For more information, see Amazon ECS-optimized AMIs.
You must define either machineImage
or machineImageType
, not both.
Default: - Automatically updated, ECS-optimized Amazon Linux 2