Interface AsgCapacityProviderProps

All Superinterfaces:
AddAutoScalingGroupCapacityOptions, software.amazon.jsii.JsiiSerializable
All Known Implementing Classes:
AsgCapacityProviderProps.Jsii$Proxy

@Generated(value="jsii-pacmak/1.97.0 (build 729de35)", date="2024-04-24T21:00:29.099Z") @Stability(Stable) public interface AsgCapacityProviderProps extends software.amazon.jsii.JsiiSerializable, AddAutoScalingGroupCapacityOptions
The options for creating an Auto Scaling Group Capacity Provider.

Example:

 Vpc vpc;
 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);
 
  • Method Details

    • getAutoScalingGroup

      @Stability(Stable) @NotNull IAutoScalingGroup getAutoScalingGroup()
      The autoscaling group to add as a Capacity Provider.
    • getCapacityProviderName

      @Stability(Stable) @Nullable default String getCapacityProviderName()
      The name of the capacity provider.

      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. If the stack name starts with aws, ecs, or fargate, a unique resource name is generated that starts with cp-.

      Default: CloudFormation-generated name

    • getEnableManagedDraining

      @Stability(Stable) @Nullable default Boolean getEnableManagedDraining()
      Managed instance draining facilitates graceful termination of Amazon ECS instances.

      This allows your service workloads to stop safely and be rescheduled to non-terminating instances. Infrastructure maintenance and updates are preformed without disruptions to workloads. To use managed instance draining, set enableManagedDraining to true.

      Default: true

    • getEnableManagedScaling

      @Stability(Stable) @Nullable default Boolean getEnableManagedScaling()
      When enabled the scale-in and scale-out actions of the cluster's Auto Scaling Group will be managed for you.

      This means your cluster will automatically scale instances based on the load your tasks put on the cluster. For more information, see Using Managed Scaling in the ECS Developer Guide.

      Default: true

    • getEnableManagedTerminationProtection

      @Stability(Stable) @Nullable default Boolean getEnableManagedTerminationProtection()
      When enabled the Auto Scaling Group will only terminate EC2 instances that no longer have running non-daemon tasks.

      Scale-in protection will be automatically enabled on instances. When all non-daemon tasks are stopped on an instance, ECS initiates the scale-in process and turns off scale-in protection for the instance. The Auto Scaling Group can then terminate the instance. For more information see Managed termination protection in the ECS Developer Guide.

      Managed scaling must also be enabled.

      Default: true

    • getInstanceWarmupPeriod

      @Stability(Stable) @Nullable default Number getInstanceWarmupPeriod()
      The period of time, in seconds, after a newly launched Amazon EC2 instance can contribute to CloudWatch metrics for Auto Scaling group.

      Must be between 0 and 10000.

      Default: 300

    • getMaximumScalingStepSize

      @Stability(Stable) @Nullable default Number getMaximumScalingStepSize()
      Maximum scaling step size.

      In most cases this should be left alone.

      Default: 1000

    • getMinimumScalingStepSize

      @Stability(Stable) @Nullable default Number getMinimumScalingStepSize()
      Minimum scaling step size.

      In most cases this should be left alone.

      Default: 1

    • getTargetCapacityPercent

      @Stability(Stable) @Nullable default Number getTargetCapacityPercent()
      Target capacity percent.

      In most cases this should be left alone.

      Default: 100

    • builder

      @Stability(Stable) static AsgCapacityProviderProps.Builder builder()
      Returns:
      a AsgCapacityProviderProps.Builder of AsgCapacityProviderProps