Skip to content
v2.278.0

AutoScalingGroup L2 construct ​

A Fleet represents a managed set of EC2 instances.

The Fleet models a number of AutoScalingGroups, a launch configuration, a security group and an instance role.

It allows adding arbitrary commands to the startup scripts of the instances in the fleet.

The ASG spans the availability zones specified by vpcSubnets, falling back to the Vpc default strategy if not specified.

Example ​

ts
declare const vpc: ec2.Vpc;

const mySecurityGroup = new ec2.SecurityGroup(this, 'SecurityGroup', { vpc });
new autoscaling.AutoScalingGroup(this, 'ASG', {
  vpc,
  instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.MICRO),
  machineImage: ec2.MachineImage.latestAmazonLinux2(),
  securityGroup: mySecurityGroup,
});
python
# vpc: ec2.Vpc


my_security_group = ec2.SecurityGroup(self, "SecurityGroup", vpc=vpc)
autoscaling.AutoScalingGroup(self, "ASG",
    vpc=vpc,
    instance_type=ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.MICRO),
    machine_image=ec2.MachineImage.latest_amazon_linux2(),
    security_group=my_security_group
)
java
Vpc vpc;


SecurityGroup mySecurityGroup = SecurityGroup.Builder.create(this, "SecurityGroup").vpc(vpc).build();
AutoScalingGroup.Builder.create(this, "ASG")
        .vpc(vpc)
        .instanceType(InstanceType.of(InstanceClass.BURSTABLE2, InstanceSize.MICRO))
        .machineImage(MachineImage.latestAmazonLinux2())
        .securityGroup(mySecurityGroup)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
Vpc vpc;


var mySecurityGroup = new SecurityGroup(this, "SecurityGroup", new SecurityGroupProps { Vpc = vpc });
new AutoScalingGroup(this, "ASG", new AutoScalingGroupProps {
    Vpc = vpc,
    InstanceType = InstanceType.Of(InstanceClass.BURSTABLE2, InstanceSize.MICRO),
    MachineImage = MachineImage.LatestAmazonLinux2(),
    SecurityGroup = mySecurityGroup
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var vpc Vpc


mySecurityGroup := ec2.NewSecurityGroup(this, jsii.String("SecurityGroup"), &SecurityGroupProps{
	Vpc: Vpc,
})
autoscaling.NewAutoScalingGroup(this, jsii.String("ASG"), &AutoScalingGroupProps{
	Vpc: Vpc,
	InstanceType: ec2.InstanceType_Of(ec2.InstanceClass_BURSTABLE2, ec2.InstanceSize_MICRO),
	MachineImage: ec2.MachineImage_LatestAmazonLinux2(),
	SecurityGroup: mySecurityGroup,
})

Initializer ​

ts
new AutoScalingGroup(scope: Construct, id: string, props: AutoScalingGroupProps)
python
AutoScalingGroup(scope: Construct, id: str, props: AutoScalingGroupProps)
java
new AutoScalingGroup(Construct scope, String id, AutoScalingGroupProps props)
csharp
new AutoScalingGroup(Construct scope, string id, AutoScalingGroupProps props)
go
NewAutoScalingGroup(Scope Construct, Id *string, Props AutoScalingGroupProps)

Construct Props ​

allowAllOutboundoptionalbooleanallow_all_outboundoptionalboolallowAllOutboundoptionalBooleanAllowAllOutboundoptionalboolAllowAllOutboundoptional*bool = true #
Whether the instances can initiate connections to anywhere by default.
associatePublicIpAddressoptionalbooleanassociate_public_ip_addressoptionalboolassociatePublicIpAddressoptionalBooleanAssociatePublicIpAddressoptionalboolAssociatePublicIpAddressoptional*bool #
Whether instances in the Auto Scaling Group should have public IP addresses associated with them.

Default: Use subnet setting.

launchTemplate and mixedInstancesPolicy must not be specified when this property is specified

autoScalingGroupNameoptionalstringauto_scaling_group_nameoptionalstrautoScalingGroupNameoptionalStringAutoScalingGroupNameoptionalstringAutoScalingGroupNameoptional*string #
The name of the Auto Scaling group.

Default: Auto generated by CloudFormation

This name must be unique per Region per account.

azCapacityDistributionStrategyoptionalCapacityDistributionStrategyaz_capacity_distribution_strategyoptionalCapacityDistributionStrategyazCapacityDistributionStrategyoptionalCapacityDistributionStrategyAzCapacityDistributionStrategyoptionalCapacityDistributionStrategyAzCapacityDistributionStrategyoptionalCapacityDistributionStrategy = None #
The strategy for distributing instances across Availability Zones.
blockDevicesoptionalBlockDevice[]block_devicesoptionaltyping.List[BlockDevice]blockDevicesoptionalList<BlockDevice>BlockDevicesoptionalBlockDevice[]BlockDevicesoptional*[]BlockDevice #
Specifies how block devices are exposed to the instance. You can specify virtual devices and EBS volumes.

Default: Uses the block device mapping of the AMI

notes

Each instance that is launched has an associated root device volume, either an Amazon EBS volume or an instance store volume. You can use block device mappings to specify additional EBS volumes or instance store volumes to attach to an instance when it is launched.

launchTemplate and mixedInstancesPolicy must not be specified when this property is specified

capacityRebalanceoptionalbooleancapacity_rebalanceoptionalboolcapacityRebalanceoptionalBooleanCapacityRebalanceoptionalboolCapacityRebalanceoptional*bool = false #
Indicates whether Capacity Rebalancing is enabled.
notes

When you turn on Capacity Rebalancing, Amazon EC2 Auto Scaling attempts to launch a Spot Instance whenever Amazon EC2 notifies that a Spot Instance is at an elevated risk of interruption. After launching a new instance, it then terminates an old instance.

cooldownoptionalDurationcooldownoptionalDurationcooldownoptionalDurationCooldownoptionalDurationCooldownoptionalDuration = Duration.minutes(5) #
Default scaling cooldown for this AutoScalingGroup.
defaultInstanceWarmupoptionalDurationdefault_instance_warmupoptionalDurationdefaultInstanceWarmupoptionalDurationDefaultInstanceWarmupoptionalDurationDefaultInstanceWarmupoptionalDuration = None #
The amount of time, in seconds, until a newly launched instance can contribute to the Amazon CloudWatch metrics.
notes

This delay lets an instance finish initializing before Amazon EC2 Auto Scaling aggregates instance metrics, resulting in more reliable usage data. Set this value equal to the amount of time that it takes for resource consumption to become stable after an instance reaches the InService state.

To optimize the performance of scaling policies that scale continuously, such as target tracking and step scaling policies, we strongly recommend that you enable the default instance warmup, even if its value is set to 0 seconds

Default instance warmup will not be added if no value is specified

deletionProtectionoptionalDeletionProtectiondeletion_protectionoptionalDeletionProtectiondeletionProtectionoptionalDeletionProtectionDeletionProtectionoptionalDeletionProtectionDeletionProtectionoptionalDeletionProtection = DeletionProtection.NONE #
Deletion protection for the Auto Scaling group.
desiredCapacityoptionalnumberdesired_capacityoptionalint | floatdesiredCapacityoptionalNumberDesiredCapacityoptionaldoubleDesiredCapacityoptional*float64 #
Initial amount of instances in the fleet.

Default: minCapacity, and leave unchanged during deployment

If this is set to a number, every deployment will reset the amount of instances to this number. It is recommended to leave this value blank.

groupMetricsoptionalGroupMetrics[]group_metricsoptionaltyping.List[GroupMetrics]groupMetricsoptionalList<GroupMetrics>GroupMetricsoptionalGroupMetrics[]GroupMetricsoptional*[]GroupMetrics #
Enable monitoring for group metrics, these metrics describe the group rather than any of its instances.

Default: no group metrics will be reported

To report all group metrics use GroupMetrics.all() Group metrics are reported in a granularity of 1 minute at no additional charge.

healthCheckoptionalHealthCheckhealth_checkoptionalHealthCheckhealthCheckoptionalHealthCheckHealthCheckoptionalHealthCheckHealthCheckoptionalHealthCheck deprecated #
Use `healthChecks` instead

Default: HealthCheck.ec2 with no grace period

healthChecksoptionalHealthCheckshealth_checksoptionalHealthCheckshealthChecksoptionalHealthChecksHealthChecksoptionalHealthChecksHealthChecksoptionalHealthChecks #
Configuration for EC2 or additional health checks.

Default: EC2 type with no grace period

Even when using HealthChecks.withAdditionalChecks(), the EC2 type is implicitly included.

ignoreUnmodifiedSizePropertiesoptionalbooleanignore_unmodified_size_propertiesoptionalboolignoreUnmodifiedSizePropertiesoptionalBooleanIgnoreUnmodifiedSizePropertiesoptionalboolIgnoreUnmodifiedSizePropertiesoptional*bool = true #
If the ASG has scheduled actions, don't reset unchanged group sizes.
notes

Only used if the ASG has scheduled actions (which may scale your ASG up or down regardless of cdk deployments). If true, the size of the group will only be reset if it has been changed in the CDK app. If false, the sizes will always be changed back to what they were in the CDK app on deployment.

initoptionalCloudFormationInitinitoptionalCloudFormationInitinitoptionalCloudFormationInitInitoptionalCloudFormationInitInitoptionalCloudFormationInit #
Apply the given CloudFormation Init configuration to the instances in the AutoScalingGroup at startup.

Default: no CloudFormation init

If you specify init, you must also specify signals to configure the number of instances to wait for and the timeout for waiting for the init process.

initOptionsoptionalApplyCloudFormationInitOptionsinit_optionsoptionalApplyCloudFormationInitOptionsinitOptionsoptionalApplyCloudFormationInitOptionsInitOptionsoptionalApplyCloudFormationInitOptionsInitOptionsoptionalApplyCloudFormationInitOptions #
Use the given options for applying CloudFormation Init.

Default: default options

Describes the configsets to use and the timeout to wait

instanceLifecyclePolicyoptionalInstanceLifecyclePolicyinstance_lifecycle_policyoptionalInstanceLifecyclePolicyinstanceLifecyclePolicyoptionalInstanceLifecyclePolicyInstanceLifecyclePolicyoptionalInstanceLifecyclePolicyInstanceLifecyclePolicyoptionalInstanceLifecyclePolicy = None #
An instance lifecycle policy that defines how instances should be handled during lifecycle events, particularly when lifecycle hooks are abandoned or fail.
instanceMonitoringoptionalMonitoringinstance_monitoringoptionalMonitoringinstanceMonitoringoptionalMonitoringInstanceMonitoringoptionalMonitoringInstanceMonitoringoptionalMonitoring = Monitoring.DETAILED #
Controls whether instances in this group are launched with detailed or basic monitoring.
notes

When detailed monitoring is enabled, Amazon CloudWatch generates metrics every minute and your account is charged a fee. When you disable detailed monitoring, CloudWatch generates metrics every 5 minutes.

launchTemplate and mixedInstancesPolicy must not be specified when this property is specified

instanceTypeoptionalInstanceTypeinstance_typeoptionalInstanceTypeinstanceTypeoptionalInstanceTypeInstanceTypeoptionalInstanceTypeInstanceTypeoptionalInstanceType #
Type of instance to launch.

Default: Do not provide any instance type

launchTemplate and mixedInstancesPolicy must not be specified when this property is specified

keyNameoptionalstringkey_nameoptionalstrkeyNameoptionalStringKeyNameoptionalstringKeyNameoptional*string deprecated #
- Use `keyPair` instead - https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2-readme.html#using-an-existing-ec2-key-pair

Default: No SSH access will be possible.

launchTemplate and mixedInstancesPolicy must not be specified when this property is specified

You can either specify keyPair or keyName, not both.

keyPairoptionalIKeyPairkey_pairoptionalIKeyPairkeyPairoptionalIKeyPairKeyPairoptionalIKeyPairKeyPairoptionalIKeyPair #
The SSH keypair to grant access to the instance.

Default: No SSH access will be possible.

notes

Feature flag AUTOSCALING_GENERATE_LAUNCH_TEMPLATE must be enabled to use this property.

launchTemplate and mixedInstancesPolicy must not be specified when this property is specified.

You can either specify keyPair or keyName, not both.

launchTemplateoptionalILaunchTemplatelaunch_templateoptionalILaunchTemplatelaunchTemplateoptionalILaunchTemplateLaunchTemplateoptionalILaunchTemplateLaunchTemplateoptionalILaunchTemplate #
Launch template to use.

Default: Do not provide any launch template

Launch configuration related settings and MixedInstancesPolicy must not be specified when a launch template is specified.

machineImageoptionalIMachineImagemachine_imageoptionalIMachineImagemachineImageoptionalIMachineImageMachineImageoptionalIMachineImageMachineImageoptionalIMachineImage #
AMI to launch.

Default: Do not provide any machine image

launchTemplate and mixedInstancesPolicy must not be specified when this property is specified

maxCapacityoptionalnumbermax_capacityoptionalint | floatmaxCapacityoptionalNumberMaxCapacityoptionaldoubleMaxCapacityoptional*float64 = desiredCapacity #
Maximum number of instances in the fleet.
maxHealthyPercentageoptionalnumbermax_healthy_percentageoptionalint | floatmaxHealthyPercentageoptionalNumberMaxHealthyPercentageoptionaldoubleMaxHealthyPercentageoptional*float64 #
Specifies the upper threshold as a percentage of the desired capacity of the Auto Scaling group.

Default: No instance maintenance policy.

notes

It represents the maximum percentage of the group that can be in service and healthy, or pending, to support your workload when replacing instances.

Value range is 0 to 100. After it's set, both minHealthyPercentage and maxHealthyPercentage to -1 will clear the previously set value.

Both or neither of minHealthyPercentage and maxHealthyPercentage must be specified, and the difference between them cannot be greater than 100. A large range increases the number of instances that can be replaced at the same time.

maxInstanceLifetimeoptionalDurationmax_instance_lifetimeoptionalDurationmaxInstanceLifetimeoptionalDurationMaxInstanceLifetimeoptionalDurationMaxInstanceLifetimeoptionalDuration = none #
The maximum amount of time that an instance can be in service.
notes

The maximum duration applies to all current and future instances in the group. As an instance approaches its maximum duration, it is terminated and replaced, and cannot be used again.

You must specify a value of at least 86,400 seconds (one day). To clear a previously set value, leave this property undefined.

migrateToLaunchTemplateoptionalbooleanmigrate_to_launch_templateoptionalboolmigrateToLaunchTemplateoptionalBooleanMigrateToLaunchTemplateoptionalboolMigrateToLaunchTemplateoptional*bool = false #
Whether safety guardrail should be enforced when migrating to the launch template.
minCapacityoptionalnumbermin_capacityoptionalint | floatminCapacityoptionalNumberMinCapacityoptionaldoubleMinCapacityoptional*float64 = 1 #
Minimum number of instances in the fleet.
minHealthyPercentageoptionalnumbermin_healthy_percentageoptionalint | floatminHealthyPercentageoptionalNumberMinHealthyPercentageoptionaldoubleMinHealthyPercentageoptional*float64 #
Specifies the lower threshold as a percentage of the desired capacity of the Auto Scaling group.

Default: No instance maintenance policy.

notes

It represents the minimum percentage of the group to keep in service, healthy, and ready to use to support your workload when replacing instances.

Value range is 0 to 100. After it's set, both minHealthyPercentage and maxHealthyPercentage to -1 will clear the previously set value.

Both or neither of minHealthyPercentage and maxHealthyPercentage must be specified, and the difference between them cannot be greater than 100. A large range increases the number of instances that can be replaced at the same time.

mixedInstancesPolicyoptionalMixedInstancesPolicymixed_instances_policyoptionalMixedInstancesPolicymixedInstancesPolicyoptionalMixedInstancesPolicyMixedInstancesPolicyoptionalMixedInstancesPolicyMixedInstancesPolicyoptionalMixedInstancesPolicy #
Mixed Instances Policy to use.

Default: Do not provide any MixedInstancesPolicy

Launch configuration related settings and Launch Template must not be specified when a MixedInstancesPolicy is specified.

newInstancesProtectedFromScaleInoptionalbooleannew_instances_protected_from_scale_inoptionalboolnewInstancesProtectedFromScaleInoptionalBooleanNewInstancesProtectedFromScaleInoptionalboolNewInstancesProtectedFromScaleInoptional*bool = false #
Whether newly-launched instances are protected from termination by Amazon EC2 Auto Scaling when scaling in.
notes

By default, Auto Scaling can terminate an instance at any time after launch when scaling in an Auto Scaling Group, subject to the group's termination policy. However, you may wish to protect newly-launched instances from being scaled in if they are going to run critical applications that should not be prematurely terminated.

This flag must be enabled if the Auto Scaling Group will be associated with an ECS Capacity Provider with managed termination protection.

notificationsoptionalNotificationConfiguration[]notificationsoptionaltyping.List[NotificationConfiguration]notificationsoptionalList<NotificationConfiguration>NotificationsoptionalNotificationConfiguration[]Notificationsoptional*[]NotificationConfiguration #
Configure autoscaling group to send notifications about fleet changes to an SNS topic(s).

Default: No fleet change notifications will be sent.

requireImdsv2optionalbooleanrequire_imdsv2optionalboolrequireImdsv2optionalBooleanRequireImdsv2optionalboolRequireImdsv2optional*bool = false #
Whether IMDSv2 should be required on launched instances.
roleoptionalIRoleroleoptionalIRoleroleoptionalIRoleRoleoptionalIRoleRoleoptionalIRole #
An IAM role to associate with the instance profile assigned to this Auto Scaling Group.

Default: A role will automatically be created, it can be accessed via the role property

The role must be assumable by the service principal ec2.amazonaws.com:

launchTemplate and mixedInstancesPolicy must not be specified when this property is specified

example
ts
   const role = new iam.Role(this, 'MyRole', {
     assumedBy: new iam.ServicePrincipal('ec2.amazonaws.com')
   });
securityGroupoptionalISecurityGroupsecurity_groupoptionalISecurityGroupsecurityGroupoptionalISecurityGroupSecurityGroupoptionalISecurityGroupSecurityGroupoptionalISecurityGroup #
Security group to launch the instances in.

Default: A SecurityGroup will be created if none is specified.

launchTemplate and mixedInstancesPolicy must not be specified when this property is specified

signalsoptionalSignalssignalsoptionalSignalssignalsoptionalSignalsSignalsoptionalSignalsSignalsoptionalSignals #
Configure waiting for signals during deployment.

Default: Do not wait for signals

notes

Use this to pause the CloudFormation deployment to wait for the instances in the AutoScalingGroup to report successful startup during creation and updates. The UserData script needs to invoke cfn-signal with a success or failure code after it is done setting up the instance.

Without waiting for signals, the CloudFormation deployment will proceed as soon as the AutoScalingGroup has been created or updated but before the instances in the group have been started.

For example, to have instances wait for an Elastic Load Balancing health check before they signal success, add a health-check verification by using the cfn-init helper script. For an example, see the verify_instance_health command in the Auto Scaling rolling updates sample template:

https://github.com/awslabs/aws-cloudformation-templates/blob/master/aws/services/AutoScaling/AutoScalingRollingUpdates.yaml

spotPriceoptionalstringspot_priceoptionalstrspotPriceoptionalStringSpotPriceoptionalstringSpotPriceoptional*string = none #
The maximum hourly price (in USD) to be paid for any Spot Instance launched to fulfill the request.

Spot Instances are launched when the price you specify exceeds the current Spot market price.

launchTemplate and mixedInstancesPolicy must not be specified when this property is specified

ssmSessionPermissionsoptionalbooleanssm_session_permissionsoptionalboolssmSessionPermissionsoptionalBooleanSsmSessionPermissionsoptionalboolSsmSessionPermissionsoptional*bool = false #
Add SSM session permissions to the instance role.
notes

Setting this to true adds the necessary permissions to connect to the instance using SSM Session Manager. You can do this from the AWS Console.

NOTE: Setting this flag to true may not be enough by itself. You must also use an AMI that comes with the SSM Agent, or install the SSM Agent yourself. See Working with SSM Agent in the SSM Developer Guide.

terminationPoliciesoptionalTerminationPolicy[]termination_policiesoptionaltyping.List[TerminationPolicy]terminationPoliciesoptionalList<TerminationPolicy>TerminationPoliciesoptionalTerminationPolicy[]TerminationPoliciesoptional*[]TerminationPolicy = `TerminationPolicy.DEFAULT` #
A policy or a list of policies that are used to select the instances to terminate.

The policies are executed in the order that you list them.

terminationPolicyCustomLambdaFunctionArnoptionalstringtermination_policy_custom_lambda_function_arnoptionalstrterminationPolicyCustomLambdaFunctionArnoptionalStringTerminationPolicyCustomLambdaFunctionArnoptionalstringTerminationPolicyCustomLambdaFunctionArnoptional*string #
A lambda function Arn that can be used as a custom termination policy to select the instances to terminate.

Default: No lambda function Arn will be supplied

This property must be specified if the TerminationPolicy.CUSTOM_LAMBDA_FUNCTION is used.

updatePolicyoptionalUpdatePolicyupdate_policyoptionalUpdatePolicyupdatePolicyoptionalUpdatePolicyUpdatePolicyoptionalUpdatePolicyUpdatePolicyoptionalUpdatePolicy #
What to do when an AutoScalingGroup's instance configuration is changed.

Default: UpdatePolicy.rollingUpdate() if using init, UpdatePolicy.none() otherwise

notes

This is applied when any of the settings on the ASG are changed that affect how the instances should be created (VPC, instance type, startup scripts, etc.). It indicates how the existing instances should be replaced with new instances matching the new config. By default, nothing is done and only new instances are launched with the new config.

userDataoptionalUserDatauser_dataoptionalUserDatauserDataoptionalUserDataUserDataoptionalUserDataUserDataoptionalUserData #
Specific UserData to use.

Default: A UserData object appropriate for the MachineImage's Operating System is created.

The UserData may still be mutated after creation.

launchTemplate and mixedInstancesPolicy must not be specified when this property is specified

vpcIVpcvpcIVpcvpcIVpcVpcIVpcVpcIVpc required #
VPC to launch these instances in.
vpcSubnetsoptionalSubnetSelectionvpc_subnetsoptionalSubnetSelectionvpcSubnetsoptionalSubnetSelectionVpcSubnetsoptionalSubnetSelectionVpcSubnetsoptionalSubnetSelection #
Where to place instances within the VPC.

Default: All Private subnets.

Properties ​

autoScalingGroupArnstringauto_scaling_group_arnstrautoScalingGroupArnStringAutoScalingGroupArnstringAutoScalingGroupArn*string #
Arn of the AutoScalingGroup.
autoScalingGroupNamestringauto_scaling_group_namestrautoScalingGroupNameStringAutoScalingGroupNamestringAutoScalingGroupName*string #
Name of the AutoScalingGroup.
autoScalingGroupRefAutoScalingGroupReferenceauto_scaling_group_refAutoScalingGroupReferenceautoScalingGroupRefAutoScalingGroupReferenceAutoScalingGroupRefAutoScalingGroupReferenceAutoScalingGroupRefAutoScalingGroupReference #
A reference to a AutoScalingGroup resource.
connectionsConnectionsconnectionsConnectionsconnectionsConnectionsConnectionsConnectionsConnectionsConnections #
The network connections associated with this resource.
The environment this resource belongs to.
notes

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

grantPrincipalIPrincipalgrant_principalIPrincipalgrantPrincipalIPrincipalGrantPrincipalIPrincipalGrantPrincipalIPrincipal #
The principal to grant permissions to.
maxInstanceLifetimemay be undefinedDurationmax_instance_lifetimemay be undefinedDurationmaxInstanceLifetimemay be undefinedDurationMaxInstanceLifetimemay be undefinedDurationMaxInstanceLifetimemay be undefinedDuration #
The maximum amount of time that an instance can be in service.
nodeNodenodeNodenodeNodeNodeNodeNodeNode #
The tree node.
The type of OS instances of this fleet are running.
PROPERTY_INJECTION_IDstringPROPERTY_INJECTION_IDstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*string static #
Uniquely identifies this class.
roleIRoleroleIRoleroleIRoleRoleIRoleRoleIRole #
The IAM Role in the instance profile.
spotPricemay be undefinedstringspot_pricemay be undefinedstrspotPricemay be undefinedStringSpotPricemay be undefinedstringSpotPricemay be undefined*string #
The maximum spot price configured for the autoscaling group.

undefined indicates that this group uses on-demand capacity.

stackStackstackStackstackStackStackStackStackStack #
The stack in which this resource is defined.
userDataUserDatauser_dataUserDatauserDataUserDataUserDataUserDataUserDataUserData #
The Base64-encoded user data to make available to the launched EC2 instances.

Methods ​

addLifecycleHook(id: string, props: BasicLifecycleHookProps): LifecycleHookdef add_lifecycle_hook(self, id: str, props: BasicLifecycleHookProps) -> LifecycleHookpublic LifecycleHook addLifecycleHook(String id, BasicLifecycleHookProps props)public LifecycleHook AddLifecycleHook(string id, BasicLifecycleHookProps props)func AddLifecycleHook(Id *string, Props BasicLifecycleHookProps) LifecycleHook #
Send a message to either an SQS queue or SNS topic when instances launch or terminate.
addSecurityGroup(securityGroup: ISecurityGroup): voiddef add_security_group(self, security_group: ISecurityGroup) -> Nonepublic void addSecurityGroup(ISecurityGroup securityGroup)public void AddSecurityGroup(ISecurityGroup securityGroup)func AddSecurityGroup(SecurityGroup ISecurityGroup) #
Add the security group to all instances via the launch template security groups array.
1 parameter

Parameters

  • securityGroupsecurity_groupsecurityGroupsecurityGroupSecurityGroup — : The security group to add.
addToRolePolicy(statement: PolicyStatement): voiddef add_to_role_policy(self, statement: PolicyStatement) -> Nonepublic void addToRolePolicy(PolicyStatement statement)public void AddToRolePolicy(PolicyStatement statement)func AddToRolePolicy(Statement PolicyStatement) #
Adds a statement to the IAM role assumed by instances of this fleet.
addUserData(...commands: string[]): voiddef add_user_data(self, commands: str) -> Nonepublic void addUserData(String commands)public void AddUserData(string commands)func AddUserData(Commands *string) #
Add command to the startup script of fleet instances.

The command must be in the scripting language supported by the fleet's OS (i.e. Linux/Windows). Does nothing for imported ASGs.

addWarmPool(options?: WarmPoolOptions): WarmPooldef add_warm_pool(self, options: typing.Optional[WarmPoolOptions] = None) -> WarmPoolpublic WarmPool addWarmPool(WarmPoolOptions options)public WarmPool AddWarmPool(WarmPoolOptions? options = null)func AddWarmPool(Options WarmPoolOptions) WarmPool #
Add a pool of pre-initialized EC2 instances that sits alongside an Auto Scaling group.
applyCloudFormationInit(init: CloudFormationInit, options?: ApplyCloudFormationInitOptions): voiddef apply_cloud_formation_init(self, init: CloudFormationInit, options: typing.Optional[ApplyCloudFormationInitOptions] = None) -> Nonepublic void applyCloudFormationInit(CloudFormationInit init, ApplyCloudFormationInitOptions options)public void ApplyCloudFormationInit(CloudFormationInit init, ApplyCloudFormationInitOptions? options = null)func ApplyCloudFormationInit(Init CloudFormationInit, Options ApplyCloudFormationInitOptions) #
Use a CloudFormation Init configuration at instance startup.
notes

This does the following:

  • Attaches the CloudFormation Init metadata to the AutoScalingGroup resource.
  • Add commands to the UserData to run cfn-init and cfn-signal.
  • Update the instance's CreationPolicy to wait for cfn-init to finish before reporting success.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength) #
Override the cross-stack reference strength for this resource.
notes · 1 parameter

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy) #
Apply the given removal policy to this resource.
notes

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

areNewInstancesProtectedFromScaleIn(): booleandef are_new_instances_protected_from_scale_in(self, ) -> boolpublic Boolean areNewInstancesProtectedFromScaleIn()public bool AreNewInstancesProtectedFromScaleIn()func AreNewInstancesProtectedFromScaleIn() *bool #
Returns `true` if newly-launched instances are protected from scale-in.
attachToApplicationTargetGroup(targetGroup: IApplicationTargetGroup): LoadBalancerTargetPropsdef attach_to_application_target_group(self, target_group: IApplicationTargetGroup) -> LoadBalancerTargetPropspublic LoadBalancerTargetProps attachToApplicationTargetGroup(IApplicationTargetGroup targetGroup)public LoadBalancerTargetProps AttachToApplicationTargetGroup(IApplicationTargetGroup targetGroup)func AttachToApplicationTargetGroup(TargetGroup IApplicationTargetGroup) LoadBalancerTargetProps #
Attach to ELBv2 Application Target Group.
attachToClassicLB(loadBalancer: LoadBalancer): voiddef attach_to_classic_lb(self, load_balancer: LoadBalancer) -> Nonepublic void attachToClassicLB(LoadBalancer loadBalancer)public void AttachToClassicLB(LoadBalancer loadBalancer)func AttachToClassicLB(LoadBalancer LoadBalancer) #
Attach to a classic load balancer.
attachToNetworkTargetGroup(targetGroup: INetworkTargetGroup): LoadBalancerTargetPropsdef attach_to_network_target_group(self, target_group: INetworkTargetGroup) -> LoadBalancerTargetPropspublic LoadBalancerTargetProps attachToNetworkTargetGroup(INetworkTargetGroup targetGroup)public LoadBalancerTargetProps AttachToNetworkTargetGroup(INetworkTargetGroup targetGroup)func AttachToNetworkTargetGroup(TargetGroup INetworkTargetGroup) LoadBalancerTargetProps #
Attach to ELBv2 Application Target Group.
fromAutoScalingGroupName(scope: Construct, id: string, autoScalingGroupName: string): IAutoScalingGroup@staticmethod def from_auto_scaling_group_name(scope: Construct, id: str, auto_scaling_group_name: str) -> IAutoScalingGrouppublic static IAutoScalingGroup fromAutoScalingGroupName(Construct scope, String id, String autoScalingGroupName)public static IAutoScalingGroup FromAutoScalingGroupName(Construct scope, string id, string autoScalingGroupName)func FromAutoScalingGroupName(Scope Construct, Id *string, AutoScalingGroupName *string) IAutoScalingGroup static #
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *bool static #
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *bool static #
Returns true if the construct was created by CDK, and false otherwise.
isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *bool static #
Check whether the given construct is a Resource.
protectNewInstancesFromScaleIn(): voiddef protect_new_instances_from_scale_in(self, ) -> Nonepublic void protectNewInstancesFromScaleIn()public void ProtectNewInstancesFromScaleIn()func ProtectNewInstancesFromScaleIn() #
Ensures newly-launched instances are protected from scale-in.
scaleOnCpuUtilization(id: string, props: CpuUtilizationScalingProps): TargetTrackingScalingPolicydef scale_on_cpu_utilization(self, id: str, props: CpuUtilizationScalingProps) -> TargetTrackingScalingPolicypublic TargetTrackingScalingPolicy scaleOnCpuUtilization(String id, CpuUtilizationScalingProps props)public TargetTrackingScalingPolicy ScaleOnCpuUtilization(string id, CpuUtilizationScalingProps props)func ScaleOnCpuUtilization(Id *string, Props CpuUtilizationScalingProps) TargetTrackingScalingPolicy #
Scale out or in to achieve a target CPU utilization.
scaleOnIncomingBytes(id: string, props: NetworkUtilizationScalingProps): TargetTrackingScalingPolicydef scale_on_incoming_bytes(self, id: str, props: NetworkUtilizationScalingProps) -> TargetTrackingScalingPolicypublic TargetTrackingScalingPolicy scaleOnIncomingBytes(String id, NetworkUtilizationScalingProps props)public TargetTrackingScalingPolicy ScaleOnIncomingBytes(string id, NetworkUtilizationScalingProps props)func ScaleOnIncomingBytes(Id *string, Props NetworkUtilizationScalingProps) TargetTrackingScalingPolicy #
Scale out or in to achieve a target network ingress rate.
scaleOnMetric(id: string, props: BasicStepScalingPolicyProps): StepScalingPolicydef scale_on_metric(self, id: str, props: BasicStepScalingPolicyProps) -> StepScalingPolicypublic StepScalingPolicy scaleOnMetric(String id, BasicStepScalingPolicyProps props)public StepScalingPolicy ScaleOnMetric(string id, BasicStepScalingPolicyProps props)func ScaleOnMetric(Id *string, Props BasicStepScalingPolicyProps) StepScalingPolicy #
Scale out or in, in response to a metric.
scaleOnOutgoingBytes(id: string, props: NetworkUtilizationScalingProps): TargetTrackingScalingPolicydef scale_on_outgoing_bytes(self, id: str, props: NetworkUtilizationScalingProps) -> TargetTrackingScalingPolicypublic TargetTrackingScalingPolicy scaleOnOutgoingBytes(String id, NetworkUtilizationScalingProps props)public TargetTrackingScalingPolicy ScaleOnOutgoingBytes(string id, NetworkUtilizationScalingProps props)func ScaleOnOutgoingBytes(Id *string, Props NetworkUtilizationScalingProps) TargetTrackingScalingPolicy #
Scale out or in to achieve a target network egress rate.
scaleOnRequestCount(id: string, props: RequestCountScalingProps): TargetTrackingScalingPolicydef scale_on_request_count(self, id: str, props: RequestCountScalingProps) -> TargetTrackingScalingPolicypublic TargetTrackingScalingPolicy scaleOnRequestCount(String id, RequestCountScalingProps props)public TargetTrackingScalingPolicy ScaleOnRequestCount(string id, RequestCountScalingProps props)func ScaleOnRequestCount(Id *string, Props RequestCountScalingProps) TargetTrackingScalingPolicy #
Scale out or in to achieve a target request handling rate.

The AutoScalingGroup must have been attached to an Application Load Balancer in order to be able to call this.

scaleOnSchedule(id: string, props: BasicScheduledActionProps): ScheduledActiondef scale_on_schedule(self, id: str, props: BasicScheduledActionProps) -> ScheduledActionpublic ScheduledAction scaleOnSchedule(String id, BasicScheduledActionProps props)public ScheduledAction ScaleOnSchedule(string id, BasicScheduledActionProps props)func ScaleOnSchedule(Id *string, Props BasicScheduledActionProps) ScheduledAction #
Scale out or in based on time.
scaleToTrackMetric(id: string, props: MetricTargetTrackingProps): TargetTrackingScalingPolicydef scale_to_track_metric(self, id: str, props: MetricTargetTrackingProps) -> TargetTrackingScalingPolicypublic TargetTrackingScalingPolicy scaleToTrackMetric(String id, MetricTargetTrackingProps props)public TargetTrackingScalingPolicy ScaleToTrackMetric(string id, MetricTargetTrackingProps props)func ScaleToTrackMetric(Id *string, Props MetricTargetTrackingProps) TargetTrackingScalingPolicy #
Scale out or in in order to keep a metric around a target value.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string #
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct #
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.