Class AsgCapacityProvider
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.services.ecs.AsgCapacityProvider
- All Implemented Interfaces:
IConstruct
,IDependable
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)",
date="2023-06-19T16:30:46.978Z")
@Stability(Stable)
public class AsgCapacityProvider
extends Construct
An Auto Scaling Group Capacity Provider.
This allows an ECS cluster to target a specific EC2 Auto Scaling Group for the placement of tasks. Optionally (and recommended), ECS can manage the number of instances in the ASG to fit the tasks, and can ensure that instances are not prematurely terminated while there are still tasks running on them.
Example:
Vpc vpc; Cluster cluster = Cluster.Builder.create(this, "Cluster") .vpc(vpc) .build(); AutoScalingGroup autoScalingGroup = AutoScalingGroup.Builder.create(this, "ASG") .vpc(vpc) .instanceType(new InstanceType("t2.micro")) .machineImage(EcsOptimizedImage.amazonLinux2()) .minCapacity(0) .maxCapacity(100) .build(); AsgCapacityProvider capacityProvider = AsgCapacityProvider.Builder.create(this, "AsgCapacityProvider") .autoScalingGroup(autoScalingGroup) .build(); cluster.addAsgCapacityProvider(capacityProvider); Ec2TaskDefinition taskDefinition = new Ec2TaskDefinition(this, "TaskDef"); taskDefinition.addContainer("web", ContainerDefinitionOptions.builder() .image(ContainerImage.fromRegistry("amazon/amazon-ecs-sample")) .memoryReservationMiB(256) .build()); Ec2Service.Builder.create(this, "EC2Service") .cluster(cluster) .taskDefinition(taskDefinition) .capacityProviderStrategies(List.of(CapacityProviderStrategy.builder() .capacityProvider(capacityProvider.getCapacityProviderName()) .weight(1) .build())) .build();
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$Default, IConstruct.Jsii$Proxy
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default, software.constructs.IConstruct.Jsii$Proxy
-
Constructor Summary
ModifierConstructorDescriptionprotected
AsgCapacityProvider
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
AsgCapacityProvider
(software.amazon.jsii.JsiiObjectRef objRef) AsgCapacityProvider
(software.constructs.Construct scope, String id, AsgCapacityProviderProps props) -
Method Summary
Modifier and TypeMethodDescriptionAuto Scaling Group.Specifies whether the containers can access the container instance role.Capacity provider name.Whether managed termination protection is enabled.Auto Scaling Group machineImageType.Methods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
Methods inherited from class software.constructs.Construct
toString
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
AsgCapacityProvider
protected AsgCapacityProvider(software.amazon.jsii.JsiiObjectRef objRef) -
AsgCapacityProvider
protected AsgCapacityProvider(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
AsgCapacityProvider
@Stability(Stable) public AsgCapacityProvider(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull AsgCapacityProviderProps props) - Parameters:
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.
-
-
Method Details
-
getAutoScalingGroup
Auto Scaling Group. -
getCapacityProviderName
Capacity provider name.Default: Chosen by CloudFormation
-
getMachineImageType
Auto Scaling Group machineImageType. -
getCanContainersAccessInstanceRole
Specifies whether the containers can access the container instance role.Default: false
-
getEnableManagedTerminationProtection
Whether managed termination protection is enabled.
-