Interface ManagedInstancesCapacityProviderProps

All Superinterfaces:
software.amazon.jsii.JsiiSerializable
All Known Implementing Classes:
ManagedInstancesCapacityProviderProps.Jsii$Proxy

@Generated(value="jsii-pacmak/1.113.0 (build fc68b25)", date="2025-10-01T17:46:53.016Z") @Stability(Stable) public interface ManagedInstancesCapacityProviderProps extends software.amazon.jsii.JsiiSerializable
The options for creating a Managed Instances Capacity Provider.

Example:

 Vpc vpc;
 Role infrastructureRole;
 InstanceProfile instanceProfile;
 Cluster cluster = Cluster.Builder.create(this, "Cluster").vpc(vpc).build();
 // Create a Managed Instances Capacity Provider
 ManagedInstancesCapacityProvider miCapacityProvider = ManagedInstancesCapacityProvider.Builder.create(this, "MICapacityProvider")
         .infrastructureRole(infrastructureRole)
         .ec2InstanceProfile(instanceProfile)
         .subnets(vpc.getPrivateSubnets())
         .securityGroups(List.of(SecurityGroup.Builder.create(this, "MISecurityGroup").vpc(vpc).build()))
         .instanceRequirements(InstanceRequirementsConfig.builder()
                 .vCpuCountMin(1)
                 .memoryMin(Size.gibibytes(2))
                 .cpuManufacturers(List.of(CpuManufacturer.INTEL))
                 .acceleratorManufacturers(List.of(AcceleratorManufacturer.NVIDIA))
                 .build())
         .propagateTags(PropagateManagedInstancesTags.CAPACITY_PROVIDER)
         .build();
 // Add the capacity provider to the cluster
 cluster.addManagedInstancesCapacityProvider(miCapacityProvider);
 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)
         .minHealthyPercent(100)
         .capacityProviderStrategies(List.of(CapacityProviderStrategy.builder()
                 .capacityProvider(miCapacityProvider.getCapacityProviderName())
                 .weight(1)
                 .build()))
         .build();
 
  • Method Details

    • getEc2InstanceProfile

      @Stability(Stable) @NotNull IInstanceProfile getEc2InstanceProfile()
      The EC2 instance profile that will be attached to instances launched by this capacity provider.

      This instance profile must contain the necessary IAM permissions for ECS container instances to register with the cluster and run tasks. At minimum, it should include permissions for ECS agent communication, ECR image pulling, and CloudWatch logging.

    • getSubnets

      @Stability(Stable) @NotNull List<ISubnet> getSubnets()
      The VPC subnets where EC2 instances will be launched.

      This array must be non-empty and should contain subnets from the VPC where you want the managed instances to be deployed.

    • 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

    • getInfrastructureRole

      @Stability(Stable) @Nullable default IRole getInfrastructureRole()
      The IAM role that ECS uses to manage the infrastructure for the capacity provider.

      This role is used by ECS to perform actions such as launching and terminating instances, managing Auto Scaling Groups, and other infrastructure operations required for the managed instances capacity provider.

      Default: - A new role will be created with the AmazonECSInfrastructureRolePolicyForManagedInstances managed policy

    • getInstanceRequirements

      @Stability(Stable) @Nullable default InstanceRequirementsConfig getInstanceRequirements()
      The instance requirements configuration for EC2 instance selection.

      This allows you to specify detailed requirements for instance selection including vCPU count ranges, memory ranges, CPU manufacturers (Intel, AMD, AWS Graviton), instance generations, network performance requirements, and many other criteria. ECS will automatically select appropriate instance types that meet these requirements.

      Default: - no specific instance requirements, ECS will choose appropriate instances

    • getMonitoring

      @Stability(Stable) @Nullable default InstanceMonitoring getMonitoring()
      The CloudWatch monitoring configuration for the EC2 instances.

      Determines the granularity of CloudWatch metrics collection for the instances. Detailed monitoring incurs additional costs but provides better observability.

      Default: - no enhanced monitoring (basic monitoring only)

    • getPropagateTags

      @Stability(Stable) @Nullable default PropagateManagedInstancesTags getPropagateTags()
      Specifies whether to propagate tags from the capacity provider to the launched instances.

      When set to CAPACITY_PROVIDER, tags applied to the capacity provider resource will be automatically applied to all EC2 instances launched by this capacity provider.

      Default: PropagateManagedInstancesTags.NONE - no tag propagation

    • getSecurityGroups

      @Stability(Stable) @Nullable default List<ISecurityGroup> getSecurityGroups()
      The security groups to associate with the launched EC2 instances.

      These security groups control the network traffic allowed to and from the instances. If not specified, the default security group of the VPC containing the subnets will be used.

      Default: - default security group of the VPC

    • getTaskVolumeStorage

      @Stability(Stable) @Nullable default Size getTaskVolumeStorage()
      The size of the task volume storage attached to each instance.

      This storage is used for container images, container logs, and temporary files. Larger storage may be needed for workloads with large container images or applications that generate significant temporary data.

      Default: Size.gibibytes(80)

    • builder

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