Class ManagedInstancesCapacityProvider

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.services.ecs.ManagedInstancesCapacityProvider
All Implemented Interfaces:
IConnectable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.119.0 (build 1634eac)", date="2025-11-20T23:37:20.349Z") @Stability(Stable) public class ManagedInstancesCapacityProvider extends software.constructs.Construct implements IConnectable
A Managed Instances Capacity Provider.

This allows an ECS cluster to use Managed Instances for task placement with managed infrastructure.

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();
 // Optionally configure security group rules using IConnectable interface
 miCapacityProvider.connections.allowFrom(Peer.ipv4(vpc.getVpcCidrBlock()), Port.tcp(80));
 // Add the capacity provider to the cluster
 cluster.addManagedInstancesCapacityProvider(miCapacityProvider);
 TaskDefinition taskDefinition = TaskDefinition.Builder.create(this, "TaskDef")
         .memoryMiB("512")
         .cpu("256")
         .networkMode(NetworkMode.AWS_VPC)
         .compatibility(Compatibility.MANAGED_INSTANCES)
         .build();
 taskDefinition.addContainer("web", ContainerDefinitionOptions.builder()
         .image(ContainerImage.fromRegistry("amazon/amazon-ecs-sample"))
         .memoryReservationMiB(256)
         .build());
 FargateService.Builder.create(this, "FargateService")
         .cluster(cluster)
         .taskDefinition(taskDefinition)
         .minHealthyPercent(100)
         .capacityProviderStrategies(List.of(CapacityProviderStrategy.builder()
                 .capacityProvider(miCapacityProvider.getCapacityProviderName())
                 .weight(1)
                 .build()))
         .build();
 
  • Field Details

    • PROPERTY_INJECTION_ID

      @Stability(Stable) public static final String PROPERTY_INJECTION_ID
      Uniquely identifies this class.
  • Constructor Details

    • ManagedInstancesCapacityProvider

      protected ManagedInstancesCapacityProvider(software.amazon.jsii.JsiiObjectRef objRef)
    • ManagedInstancesCapacityProvider

      protected ManagedInstancesCapacityProvider(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • ManagedInstancesCapacityProvider

      @Stability(Stable) public ManagedInstancesCapacityProvider(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull ManagedInstancesCapacityProviderProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • bind

      @Stability(Stable) public void bind(@NotNull ICluster cluster)
      Associates the capacity provider with the specified cluster.

      This method is called by the cluster when adding the capacity provider.

      Parameters:
      cluster - This parameter is required.
    • getCapacityProviderName

      @Stability(Stable) @NotNull public String getCapacityProviderName()
      Capacity provider name.
    • getConnections

      @Stability(Stable) @NotNull public Connections getConnections()
      The network connections associated with this resource.
      Specified by:
      getConnections in interface IConnectable