Interface AsgCapacityProviderProps

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

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:46.980Z") @Stability(Stable) public interface AsgCapacityProviderProps extends software.amazon.jsii.JsiiSerializable, AddAutoScalingGroupCapacityOptions
The options for creating an Auto Scaling Group Capacity Provider.

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();
 
  • 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.

      Default: CloudFormation-generated name

    • getEnableManagedScaling

      @Stability(Stable) @Nullable default Boolean getEnableManagedScaling()
      Whether to enable managed scaling.

      Default: true

    • getEnableManagedTerminationProtection

      @Stability(Stable) @Nullable default Boolean getEnableManagedTerminationProtection()
      Whether to enable managed termination protection.

      Default: true

    • 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