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();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA fluent builder forManagedInstancesCapacityProvider.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.services.ec2.IConnectable
IConnectable.Jsii$Default, IConnectable.Jsii$ProxyNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default, software.constructs.IConstruct.Jsii$Proxy -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedManagedInstancesCapacityProvider(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedManagedInstancesCapacityProvider(software.amazon.jsii.JsiiObjectRef objRef) ManagedInstancesCapacityProvider(software.constructs.Construct scope, String id, ManagedInstancesCapacityProviderProps props) -
Method Summary
Modifier and TypeMethodDescriptionvoidAssociates the capacity provider with the specified cluster.Capacity provider name.The network connections associated with this resource.Methods inherited from class software.constructs.Construct
getNode, isConstruct, toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
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
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
Capacity provider name. -
getConnections
The network connections associated with this resource.- Specified by:
getConnectionsin interfaceIConnectable
-