Enum CapacityOptionType
- All Implemented Interfaces:
Serializable,Comparable<CapacityOptionType>,java.lang.constant.Constable
@Generated(value="jsii-pacmak/1.133.0 (build 0f43e37)",
date="2026-06-08T20:22:43.942Z")
@Stability(Stable)
public enum CapacityOptionType
extends Enum<CapacityOptionType>
The capacity option type for instances launched by a Managed Instances Capacity Provider.
Example:
Vpc vpc;
Cluster cluster = Cluster.Builder.create(this, "Cluster").vpc(vpc).build();
SecurityGroup securityGroup = SecurityGroup.Builder.create(this, "SecurityGroup")
.vpc(vpc)
.description("Security group for managed instances")
.build();
ManagedInstancesCapacityProvider miCapacityProvider = ManagedInstancesCapacityProvider.Builder.create(this, "MICapacityProvider")
.capacityOptionType(CapacityOptionType.SPOT)
.subnets(vpc.getPrivateSubnets())
.securityGroups(List.of(securityGroup))
.instanceRequirements(InstanceRequirementsConfig.builder()
.vCpuCountMin(1)
.memoryMin(Size.gibibytes(2))
.build())
.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 classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic CapacityOptionTypeReturns the enum constant of this type with the specified name.static CapacityOptionType[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
ON_DEMAND
Launch instances as On-Demand instances. -
SPOT
Launch instances as Spot instances.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-