@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:38.569Z") @Stability(value=Stable) public class AsgCapacityProvider extends software.constructs.Construct
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:
// Example automatically generated from non-compiling source. May contain errors.
LaunchTemplate launchTemplate = LaunchTemplate.Builder.create(this, "ASG-LaunchTemplate")
.instanceType(new InstanceType("t3.medium"))
.machineImage(EcsOptimizedImage.amazonLinux2())
.userData(UserData.forLinux())
.build();
AutoScalingGroup autoScalingGroup = AutoScalingGroup.Builder.create(this, "ASG")
.vpc(vpc)
.mixedInstancesPolicy(MixedInstancesPolicy.builder()
.instancesDistribution(InstancesDistribution.builder()
.onDemandPercentageAboveBaseCapacity(50)
.build())
.launchTemplate(launchTemplate)
.build())
.build();
Cluster cluster = Cluster.Builder.create(this, "Cluster").vpc(vpc).build();
AsgCapacityProvider capacityProvider = AsgCapacityProvider.Builder.create(this, "AsgCapacityProvider")
.autoScalingGroup(autoScalingGroup)
.machineImageType(MachineImageType.AMAZON_LINUX_2)
.build();
cluster.addAsgCapacityProvider(capacityProvider);
| Modifier and Type | Class and Description |
|---|---|
static class |
AsgCapacityProvider.Builder
A fluent builder for
AsgCapacityProvider. |
| Modifier | Constructor and Description |
|---|---|
|
AsgCapacityProvider(software.constructs.Construct scope,
String id,
AsgCapacityProviderProps props) |
protected |
AsgCapacityProvider(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
AsgCapacityProvider(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
AutoScalingGroup |
getAutoScalingGroup()
Auto Scaling Group.
|
Boolean |
getCanContainersAccessInstanceRole()
Specifies whether the containers can access the container instance role.
|
String |
getCapacityProviderName()
Capacity provider name.
|
Boolean |
getEnableManagedTerminationProtection()
Whether managed termination protection is enabled.
|
MachineImageType |
getMachineImageType()
Auto Scaling Group machineImageType.
|
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetprotected AsgCapacityProvider(software.amazon.jsii.JsiiObjectRef objRef)
protected AsgCapacityProvider(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable)
public AsgCapacityProvider(@NotNull
software.constructs.Construct scope,
@NotNull
String id,
@NotNull
AsgCapacityProviderProps props)
scope - This parameter is required.id - This parameter is required.props - This parameter is required.@Stability(value=Stable) @NotNull public AutoScalingGroup getAutoScalingGroup()
@Stability(value=Stable) @NotNull public String getCapacityProviderName()
Default: Chosen by CloudFormation
@Stability(value=Stable) @NotNull public MachineImageType getMachineImageType()
@Stability(value=Stable) @Nullable public Boolean getCanContainersAccessInstanceRole()
Default: false
@Stability(value=Stable) @Nullable public Boolean getEnableManagedTerminationProtection()
Copyright © 2022. All rights reserved.