Interface IAsgCapacityProviderProps
The options for creating an Auto Scaling Group Capacity Provider.
Inherited Members
Namespace: Amazon.CDK.AWS.ECS
Assembly: Amazon.CDK.AWS.ECS.dll
Syntax (csharp)
public interface IAsgCapacityProviderProps : IAddAutoScalingGroupCapacityOptions
Syntax (vb)
Public Interface IAsgCapacityProviderProps
Inherits 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
Properties
AutoScalingGroup | The autoscaling group to add as a Capacity Provider. |
CapacityProviderName | The name of the capacity provider. |
EnableManagedScaling | Whether to enable managed scaling. |
EnableManagedTerminationProtection | Whether to enable managed termination protection. |
MaximumScalingStepSize | Maximum scaling step size. |
MinimumScalingStepSize | Minimum scaling step size. |
TargetCapacityPercent | Target capacity percent. |
Properties
AutoScalingGroup
The autoscaling group to add as a Capacity Provider.
IAutoScalingGroup AutoScalingGroup { get; }
Property Value
CapacityProviderName
The name of the capacity provider.
virtual string CapacityProviderName { get; }
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.
virtual Nullable<bool> EnableManagedScaling { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: true
EnableManagedTerminationProtection
Whether to enable managed termination protection.
virtual Nullable<bool> EnableManagedTerminationProtection { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: true
MaximumScalingStepSize
Maximum scaling step size.
virtual Nullable<double> MaximumScalingStepSize { get; }
Property Value
System.Nullable<System.Double>
Remarks
In most cases this should be left alone.
Default: 1000
MinimumScalingStepSize
Minimum scaling step size.
virtual Nullable<double> MinimumScalingStepSize { get; }
Property Value
System.Nullable<System.Double>
Remarks
In most cases this should be left alone.
Default: 1
TargetCapacityPercent
Target capacity percent.
virtual Nullable<double> TargetCapacityPercent { get; }
Property Value
System.Nullable<System.Double>
Remarks
In most cases this should be left alone.
Default: 100