Class AsgCapacityProviderProps.Builder
java.lang.Object
software.amazon.awscdk.services.ecs.AsgCapacityProviderProps.Builder
- All Implemented Interfaces:
software.amazon.jsii.Builder<AsgCapacityProviderProps>
- Enclosing interface:
AsgCapacityProviderProps
@Stability(Stable)
public static final class AsgCapacityProviderProps.Builder
extends Object
implements software.amazon.jsii.Builder<AsgCapacityProviderProps>
A builder for
AsgCapacityProviderProps
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionautoScalingGroup
(IAutoScalingGroup autoScalingGroup) Sets the value ofAsgCapacityProviderProps.getAutoScalingGroup()
build()
Builds the configured instance.canContainersAccessInstanceRole
(Boolean canContainersAccessInstanceRole) Deprecated.See https://github.com/aws/aws-cdk/discussions/32609capacityProviderName
(String capacityProviderName) Sets the value ofAsgCapacityProviderProps.getCapacityProviderName()
enableManagedDraining
(Boolean enableManagedDraining) Sets the value ofAsgCapacityProviderProps.getEnableManagedDraining()
enableManagedScaling
(Boolean enableManagedScaling) Sets the value ofAsgCapacityProviderProps.getEnableManagedScaling()
enableManagedTerminationProtection
(Boolean enableManagedTerminationProtection) Sets the value ofAsgCapacityProviderProps.getEnableManagedTerminationProtection()
instanceWarmupPeriod
(Number instanceWarmupPeriod) Sets the value ofAsgCapacityProviderProps.getInstanceWarmupPeriod()
machineImageType
(MachineImageType machineImageType) Sets the value ofAddAutoScalingGroupCapacityOptions.getMachineImageType()
maximumScalingStepSize
(Number maximumScalingStepSize) Sets the value ofAsgCapacityProviderProps.getMaximumScalingStepSize()
minimumScalingStepSize
(Number minimumScalingStepSize) Sets the value ofAsgCapacityProviderProps.getMinimumScalingStepSize()
spotInstanceDraining
(Boolean spotInstanceDraining) Sets the value ofAddAutoScalingGroupCapacityOptions.getSpotInstanceDraining()
targetCapacityPercent
(Number targetCapacityPercent) Sets the value ofAsgCapacityProviderProps.getTargetCapacityPercent()
topicEncryptionKey
(IKey topicEncryptionKey) Sets the value ofAddAutoScalingGroupCapacityOptions.getTopicEncryptionKey()
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
autoScalingGroup
@Stability(Stable) public AsgCapacityProviderProps.Builder autoScalingGroup(IAutoScalingGroup autoScalingGroup) Sets the value ofAsgCapacityProviderProps.getAutoScalingGroup()
- Parameters:
autoScalingGroup
- The autoscaling group to add as a Capacity Provider. This parameter is required. Warning: When passing an imported resource usingAutoScalingGroup.fromAutoScalingGroupName
along withenableManagedTerminationProtection: true
, theAsgCapacityProvider
construct will not be able to enforce the optionnewInstancesProtectedFromScaleIn
of theAutoScalingGroup
. In this case the constructor ofAsgCapacityProvider
will throw an exception.- Returns:
this
-
capacityProviderName
@Stability(Stable) public AsgCapacityProviderProps.Builder capacityProviderName(String capacityProviderName) Sets the value ofAsgCapacityProviderProps.getCapacityProviderName()
- Parameters:
capacityProviderName
- The name of the capacity provider. If a name is specified, it cannot start withaws
,ecs
, orfargate
. If no name is specified, a default name in the CFNStackName-CFNResourceName-RandomString format is used. If the stack name starts withaws
,ecs
, orfargate
, a unique resource name is generated that starts withcp-
.- Returns:
this
-
enableManagedDraining
@Stability(Stable) public AsgCapacityProviderProps.Builder enableManagedDraining(Boolean enableManagedDraining) Sets the value ofAsgCapacityProviderProps.getEnableManagedDraining()
- Parameters:
enableManagedDraining
- Managed instance draining facilitates graceful termination of Amazon ECS instances. This allows your service workloads to stop safely and be rescheduled to non-terminating instances. Infrastructure maintenance and updates are preformed without disruptions to workloads. To use managed instance draining, set enableManagedDraining to true.- Returns:
this
-
enableManagedScaling
@Stability(Stable) public AsgCapacityProviderProps.Builder enableManagedScaling(Boolean enableManagedScaling) Sets the value ofAsgCapacityProviderProps.getEnableManagedScaling()
- Parameters:
enableManagedScaling
- When enabled the scale-in and scale-out actions of the cluster's Auto Scaling Group will be managed for you. This means your cluster will automatically scale instances based on the load your tasks put on the cluster. For more information, see Using Managed Scaling in the ECS Developer Guide.- Returns:
this
-
enableManagedTerminationProtection
@Stability(Stable) public AsgCapacityProviderProps.Builder enableManagedTerminationProtection(Boolean enableManagedTerminationProtection) Sets the value ofAsgCapacityProviderProps.getEnableManagedTerminationProtection()
- Parameters:
enableManagedTerminationProtection
- When enabled the Auto Scaling Group will only terminate EC2 instances that no longer have running non-daemon tasks. Scale-in protection will be automatically enabled on instances. When all non-daemon tasks are stopped on an instance, ECS initiates the scale-in process and turns off scale-in protection for the instance. The Auto Scaling Group can then terminate the instance. For more information see Managed termination protection in the ECS Developer Guide.Managed scaling must also be enabled.
- Returns:
this
-
instanceWarmupPeriod
@Stability(Stable) public AsgCapacityProviderProps.Builder instanceWarmupPeriod(Number instanceWarmupPeriod) Sets the value ofAsgCapacityProviderProps.getInstanceWarmupPeriod()
- Parameters:
instanceWarmupPeriod
- The period of time, in seconds, after a newly launched Amazon EC2 instance can contribute to CloudWatch metrics for Auto Scaling group. Must be between 0 and 10000.- Returns:
this
-
maximumScalingStepSize
@Stability(Stable) public AsgCapacityProviderProps.Builder maximumScalingStepSize(Number maximumScalingStepSize) Sets the value ofAsgCapacityProviderProps.getMaximumScalingStepSize()
- Parameters:
maximumScalingStepSize
- Maximum scaling step size. In most cases this should be left alone.- Returns:
this
-
minimumScalingStepSize
@Stability(Stable) public AsgCapacityProviderProps.Builder minimumScalingStepSize(Number minimumScalingStepSize) Sets the value ofAsgCapacityProviderProps.getMinimumScalingStepSize()
- Parameters:
minimumScalingStepSize
- Minimum scaling step size. In most cases this should be left alone.- Returns:
this
-
targetCapacityPercent
@Stability(Stable) public AsgCapacityProviderProps.Builder targetCapacityPercent(Number targetCapacityPercent) Sets the value ofAsgCapacityProviderProps.getTargetCapacityPercent()
- Parameters:
targetCapacityPercent
- Target capacity percent. In most cases this should be left alone.- Returns:
this
-
canContainersAccessInstanceRole
@Stability(Deprecated) @Deprecated public AsgCapacityProviderProps.Builder canContainersAccessInstanceRole(Boolean canContainersAccessInstanceRole) Deprecated.See https://github.com/aws/aws-cdk/discussions/32609Sets the value ofAddAutoScalingGroupCapacityOptions.getCanContainersAccessInstanceRole()
- Parameters:
canContainersAccessInstanceRole
- Specifies whether the containers can access the container instance role.- Returns:
this
-
machineImageType
@Stability(Stable) public AsgCapacityProviderProps.Builder machineImageType(MachineImageType machineImageType) Sets the value ofAddAutoScalingGroupCapacityOptions.getMachineImageType()
- Parameters:
machineImageType
- What type of machine image this is. Depending on the setting, different UserData will automatically be added to theAutoScalingGroup
to configure it properly for use with ECS.If you create an
AutoScalingGroup
yourself and are adding it viaaddAutoScalingGroup()
, you must specify this value. If you are adding anautoScalingGroup
viaaddCapacity
, this value will be determined from themachineImage
you pass.- Returns:
this
-
spotInstanceDraining
@Stability(Stable) public AsgCapacityProviderProps.Builder spotInstanceDraining(Boolean spotInstanceDraining) Sets the value ofAddAutoScalingGroupCapacityOptions.getSpotInstanceDraining()
- Parameters:
spotInstanceDraining
- Specify whether to enable Automated Draining for Spot Instances running Amazon ECS Services. For more information, see Using Spot Instances.- Returns:
this
-
topicEncryptionKey
@Stability(Stable) public AsgCapacityProviderProps.Builder topicEncryptionKey(IKey topicEncryptionKey) Sets the value ofAddAutoScalingGroupCapacityOptions.getTopicEncryptionKey()
- Parameters:
topicEncryptionKey
- IfAddAutoScalingGroupCapacityOptions.taskDrainTime
is non-zero, then the ECS cluster creates an SNS Topic to as part of a system to drain instances of tasks when the instance is being shut down. If this property is provided, then this key will be used to encrypt the contents of that SNS Topic. See SNS Data Encryption for more information.- Returns:
this
-
build
Builds the configured instance.- Specified by:
build
in interfacesoftware.amazon.jsii.Builder<AsgCapacityProviderProps>
- Returns:
- a new instance of
AsgCapacityProviderProps
- Throws:
NullPointerException
- if any required attribute was not provided
-