Interface AddCapacityOptions

All Superinterfaces:
AddAutoScalingGroupCapacityOptions, CommonAutoScalingGroupProps,
All Known Implementing Classes:

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:46.968Z") @Stability(Stable) public interface AddCapacityOptions extends, AddAutoScalingGroupCapacityOptions, CommonAutoScalingGroupProps
The properties for adding instance capacity to an AutoScalingGroup.


 Vpc vpc;
 // Create an ECS cluster
 Cluster cluster = Cluster.Builder.create(this, "Cluster")
 // Add capacity to it
 cluster.addCapacity("DefaultAutoScalingGroupCapacity", AddCapacityOptions.builder()
         .instanceType(new InstanceType("t2.xlarge"))
 Ec2TaskDefinition taskDefinition = new Ec2TaskDefinition(this, "TaskDef");
 taskDefinition.addContainer("DefaultContainer", ContainerDefinitionOptions.builder()
 // Instantiate an Amazon ECS Service
 Ec2Service ecsService = Ec2Service.Builder.create(this, "Service")
  • Method Details

    • getInstanceType

      @Stability(Stable) @NotNull InstanceType getInstanceType()
      The EC2 instance type to use when launching instances into the AutoScalingGroup.
    • getMachineImage

      @Stability(Stable) @Nullable default IMachineImage getMachineImage()
      The ECS-optimized AMI variant to use.

      The default is to use an ECS-optimized AMI of Amazon Linux 2 which is automatically updated to the latest version on every deployment. This will replace the instances in the AutoScalingGroup. Make sure you have not disabled task draining, to avoid downtime when the AMI updates.

      To use an image that does not update on every deployment, pass:

       EcsOptimizedImage machineImage = EcsOptimizedImage.amazonLinux2(AmiHardwareType.STANDARD, EcsOptimizedImageOptions.builder()

      For more information, see Amazon ECS-optimized AMIs.

      You must define either machineImage or machineImageType, not both.

      Default: - Automatically updated, ECS-optimized Amazon Linux 2

    • builder

      @Stability(Stable) static AddCapacityOptions.Builder builder()
      a AddCapacityOptions.Builder of AddCapacityOptions