Class CfnCapacityProvider

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IInspectable, ITaggable, ICapacityProviderRef, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.116.0 (build 0eddcff)", date="2025-10-29T11:15:38.975Z") @Stability(Stable) public class CfnCapacityProvider extends CfnResource implements IInspectable, ICapacityProviderRef, ITaggable
Creates a capacity provider.

Capacity providers are associated with a cluster and are used in capacity provider strategies to facilitate cluster auto scaling. You can create capacity providers for Amazon ECS Managed Instances and EC2 instances. AWS Fargate has the predefined FARGATE and FARGATE_SPOT capacity providers.

Example:

 // The code below shows an example of how to instantiate this type.
 // The values are placeholders you should change.
 import software.amazon.awscdk.services.ecs.*;
 CfnCapacityProvider cfnCapacityProvider = CfnCapacityProvider.Builder.create(this, "MyCfnCapacityProvider")
         .autoScalingGroupProvider(AutoScalingGroupProviderProperty.builder()
                 .autoScalingGroupArn("autoScalingGroupArn")
                 // the properties below are optional
                 .managedDraining("managedDraining")
                 .managedScaling(ManagedScalingProperty.builder()
                         .instanceWarmupPeriod(123)
                         .maximumScalingStepSize(123)
                         .minimumScalingStepSize(123)
                         .status("status")
                         .targetCapacity(123)
                         .build())
                 .managedTerminationProtection("managedTerminationProtection")
                 .build())
         .clusterName("clusterName")
         .managedInstancesProvider(ManagedInstancesProviderProperty.builder()
                 .infrastructureRoleArn("infrastructureRoleArn")
                 .instanceLaunchTemplate(InstanceLaunchTemplateProperty.builder()
                         .ec2InstanceProfileArn("ec2InstanceProfileArn")
                         .networkConfiguration(ManagedInstancesNetworkConfigurationProperty.builder()
                                 .subnets(List.of("subnets"))
                                 // the properties below are optional
                                 .securityGroups(List.of("securityGroups"))
                                 .build())
                         // the properties below are optional
                         .instanceRequirements(InstanceRequirementsRequestProperty.builder()
                                 .memoryMiB(MemoryMiBRequestProperty.builder()
                                         .min(123)
                                         // the properties below are optional
                                         .max(123)
                                         .build())
                                 .vCpuCount(VCpuCountRangeRequestProperty.builder()
                                         .min(123)
                                         // the properties below are optional
                                         .max(123)
                                         .build())
                                 // the properties below are optional
                                 .acceleratorCount(AcceleratorCountRequestProperty.builder()
                                         .max(123)
                                         .min(123)
                                         .build())
                                 .acceleratorManufacturers(List.of("acceleratorManufacturers"))
                                 .acceleratorNames(List.of("acceleratorNames"))
                                 .acceleratorTotalMemoryMiB(AcceleratorTotalMemoryMiBRequestProperty.builder()
                                         .max(123)
                                         .min(123)
                                         .build())
                                 .acceleratorTypes(List.of("acceleratorTypes"))
                                 .allowedInstanceTypes(List.of("allowedInstanceTypes"))
                                 .bareMetal("bareMetal")
                                 .baselineEbsBandwidthMbps(BaselineEbsBandwidthMbpsRequestProperty.builder()
                                         .max(123)
                                         .min(123)
                                         .build())
                                 .burstablePerformance("burstablePerformance")
                                 .cpuManufacturers(List.of("cpuManufacturers"))
                                 .excludedInstanceTypes(List.of("excludedInstanceTypes"))
                                 .instanceGenerations(List.of("instanceGenerations"))
                                 .localStorage("localStorage")
                                 .localStorageTypes(List.of("localStorageTypes"))
                                 .maxSpotPriceAsPercentageOfOptimalOnDemandPrice(123)
                                 .memoryGiBPerVCpu(MemoryGiBPerVCpuRequestProperty.builder()
                                         .max(123)
                                         .min(123)
                                         .build())
                                 .networkBandwidthGbps(NetworkBandwidthGbpsRequestProperty.builder()
                                         .max(123)
                                         .min(123)
                                         .build())
                                 .networkInterfaceCount(NetworkInterfaceCountRequestProperty.builder()
                                         .max(123)
                                         .min(123)
                                         .build())
                                 .onDemandMaxPricePercentageOverLowestPrice(123)
                                 .requireHibernateSupport(false)
                                 .spotMaxPricePercentageOverLowestPrice(123)
                                 .totalLocalStorageGb(TotalLocalStorageGBRequestProperty.builder()
                                         .max(123)
                                         .min(123)
                                         .build())
                                 .build())
                         .monitoring("monitoring")
                         .storageConfiguration(ManagedInstancesStorageConfigurationProperty.builder()
                                 .storageSizeGiB(123)
                                 .build())
                         .build())
                 // the properties below are optional
                 .propagateTags("propagateTags")
                 .build())
         .name("name")
         .tags(List.of(CfnTag.builder()
                 .key("key")
                 .value("value")
                 .build()))
         .build();
 

See Also:
  • Field Details

    • CFN_RESOURCE_TYPE_NAME

      @Stability(Stable) public static final String CFN_RESOURCE_TYPE_NAME
      The CloudFormation resource type name for this resource class.
  • Constructor Details

    • CfnCapacityProvider

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

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

      @Stability(Stable) public CfnCapacityProvider(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable CfnCapacityProviderProps props)
      Parameters:
      scope - Scope in which this resource is defined. This parameter is required.
      id - Construct identifier for this resource (unique in its scope). This parameter is required.
      props - Resource properties.
    • CfnCapacityProvider

      @Stability(Stable) public CfnCapacityProvider(@NotNull software.constructs.Construct scope, @NotNull String id)
      Parameters:
      scope - Scope in which this resource is defined. This parameter is required.
      id - Construct identifier for this resource (unique in its scope). This parameter is required.
  • Method Details

    • fromCapacityProviderName

      @Stability(Stable) @NotNull public static ICapacityProviderRef fromCapacityProviderName(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String capacityProviderName)
      Creates a new ICapacityProviderRef from a capacityProviderName.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      capacityProviderName - This parameter is required.
    • inspect

      @Stability(Stable) public void inspect(@NotNull TreeInspector inspector)
      Examines the CloudFormation resource and discloses attributes.

      Specified by:
      inspect in interface IInspectable
      Parameters:
      inspector - tree inspector to collect and process attributes. This parameter is required.
    • renderProperties

      @Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String,Object> props)
      Overrides:
      renderProperties in class CfnResource
      Parameters:
      props - This parameter is required.
    • getCapacityProviderRef

      @Stability(Stable) @NotNull public CapacityProviderReference getCapacityProviderRef()
      A reference to a CapacityProvider resource.
      Specified by:
      getCapacityProviderRef in interface ICapacityProviderRef
    • getCfnProperties

      @Stability(Stable) @NotNull protected Map<String,Object> getCfnProperties()
      Overrides:
      getCfnProperties in class CfnResource
    • getTags

      @Stability(Stable) @NotNull public TagManager getTags()
      Tag Manager which manages the tags for this resource.
      Specified by:
      getTags in interface ITaggable
    • getAutoScalingGroupProvider

      @Stability(Stable) @Nullable public Object getAutoScalingGroupProvider()
      The Auto Scaling group settings for the capacity provider.

      Returns union: either IResolvable or CfnCapacityProvider.AutoScalingGroupProviderProperty

    • setAutoScalingGroupProvider

      @Stability(Stable) public void setAutoScalingGroupProvider(@Nullable IResolvable value)
      The Auto Scaling group settings for the capacity provider.
    • setAutoScalingGroupProvider

      @Stability(Stable) public void setAutoScalingGroupProvider(@Nullable CfnCapacityProvider.AutoScalingGroupProviderProperty value)
      The Auto Scaling group settings for the capacity provider.
    • getClusterName

      @Stability(Stable) @Nullable public String getClusterName()
      The cluster that this capacity provider is associated with.
    • setClusterName

      @Stability(Stable) public void setClusterName(@Nullable String value)
      The cluster that this capacity provider is associated with.
    • getManagedInstancesProvider

      @Stability(Stable) @Nullable public Object getManagedInstancesProvider()
      The configuration for the Amazon ECS Managed Instances provider.

      Returns union: either IResolvable or CfnCapacityProvider.ManagedInstancesProviderProperty

    • setManagedInstancesProvider

      @Stability(Stable) public void setManagedInstancesProvider(@Nullable IResolvable value)
      The configuration for the Amazon ECS Managed Instances provider.
    • setManagedInstancesProvider

      @Stability(Stable) public void setManagedInstancesProvider(@Nullable CfnCapacityProvider.ManagedInstancesProviderProperty value)
      The configuration for the Amazon ECS Managed Instances provider.
    • getName

      @Stability(Stable) @Nullable public String getName()
      The name of the capacity provider.
    • setName

      @Stability(Stable) public void setName(@Nullable String value)
      The name of the capacity provider.
    • getTagsRaw

      @Stability(Stable) @Nullable public List<CfnTag> getTagsRaw()
      The metadata that you apply to the capacity provider to help you categorize and organize it.
    • setTagsRaw

      @Stability(Stable) public void setTagsRaw(@Nullable List<CfnTag> value)
      The metadata that you apply to the capacity provider to help you categorize and organize it.