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.
| CloudFormation | AWS::AutoScaling::AutoScalingGroup |
|---|---|
| L1 type | CfnAutoScalingGroup |
| Source | aws-autoscaling/lib/auto-scaling-group.ts |
| Type last changed |
Example
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,
});
# 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
)
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();
// 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
});
// 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
new AutoScalingGroup(scope: Construct, id: string, props: AutoScalingGroupProps)
AutoScalingGroup(scope: Construct, id: str, props: AutoScalingGroupProps)
new AutoScalingGroup(Construct scope, String id, AutoScalingGroupProps props)
new AutoScalingGroup(Construct scope, string id, AutoScalingGroupProps props)
NewAutoScalingGroup(Scope Construct, Id *string, Props AutoScalingGroupProps)
Construct Props
allowAllOutboundoptionalbooleanallow_all_outboundoptionalboolallowAllOutboundoptionalBooleanAllowAllOutboundoptionalboolAllowAllOutboundoptional*bool = true #associatePublicIpAddressoptionalbooleanassociate_public_ip_addressoptionalboolassociatePublicIpAddressoptionalBooleanAssociatePublicIpAddressoptionalboolAssociatePublicIpAddressoptional*bool #Default: Use subnet setting.
launchTemplate and mixedInstancesPolicy must not be specified when this property is specified
autoScalingGroupNameoptionalstringauto_scaling_group_nameoptionalstrautoScalingGroupNameoptionalStringAutoScalingGroupNameoptionalstringAutoScalingGroupNameoptional*string #Default: Auto generated by CloudFormation
This name must be unique per Region per account.
azCapacityDistributionStrategyoptionalCapacityDistributionStrategyaz_capacity_distribution_strategyoptionalCapacityDistributionStrategyazCapacityDistributionStrategyoptionalCapacityDistributionStrategyAzCapacityDistributionStrategyoptionalCapacityDistributionStrategyAzCapacityDistributionStrategyoptionalCapacityDistributionStrategy = None #blockDevicesoptionalBlockDevice[]block_devicesoptionaltyping.List[BlockDevice]blockDevicesoptionalList<BlockDevice>BlockDevicesoptionalBlockDevice[]BlockDevicesoptional*[]BlockDevice #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 #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) #defaultInstanceWarmupoptionalDurationdefault_instance_warmupoptionalDurationdefaultInstanceWarmupoptionalDurationDefaultInstanceWarmupoptionalDurationDefaultInstanceWarmupoptionalDuration = None #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 #desiredCapacityoptionalnumberdesired_capacityoptionalint | floatdesiredCapacityoptionalNumberDesiredCapacityoptionaldoubleDesiredCapacityoptional*float64 #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 #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 #Default: HealthCheck.ec2 with no grace period
healthChecksoptionalHealthCheckshealth_checksoptionalHealthCheckshealthChecksoptionalHealthChecksHealthChecksoptionalHealthChecksHealthChecksoptionalHealthChecks #Default: EC2 type with no grace period
Even when using HealthChecks.withAdditionalChecks(), the EC2 type is implicitly included.
ignoreUnmodifiedSizePropertiesoptionalbooleanignore_unmodified_size_propertiesoptionalboolignoreUnmodifiedSizePropertiesoptionalBooleanIgnoreUnmodifiedSizePropertiesoptionalboolIgnoreUnmodifiedSizePropertiesoptional*bool = true #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 #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 #Default: default options
Describes the configsets to use and the timeout to wait
instanceLifecyclePolicyoptionalInstanceLifecyclePolicyinstance_lifecycle_policyoptionalInstanceLifecyclePolicyinstanceLifecyclePolicyoptionalInstanceLifecyclePolicyInstanceLifecyclePolicyoptionalInstanceLifecyclePolicyInstanceLifecyclePolicyoptionalInstanceLifecyclePolicy = None #instanceMonitoringoptionalMonitoringinstance_monitoringoptionalMonitoringinstanceMonitoringoptionalMonitoringInstanceMonitoringoptionalMonitoringInstanceMonitoringoptionalMonitoring = Monitoring.DETAILED #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 #Default: Do not provide any instance type
launchTemplate and mixedInstancesPolicy must not be specified when this property is specified
keyNameoptionalstringkey_nameoptionalstrkeyNameoptionalStringKeyNameoptionalstringKeyNameoptional*string deprecated #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 #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 #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 #Default: Do not provide any machine image
launchTemplate and mixedInstancesPolicy must not be specified when this property is specified
maxCapacityoptionalnumbermax_capacityoptionalint | floatmaxCapacityoptionalNumberMaxCapacityoptionaldoubleMaxCapacityoptional*float64 = desiredCapacity #maxHealthyPercentageoptionalnumbermax_healthy_percentageoptionalint | floatmaxHealthyPercentageoptionalNumberMaxHealthyPercentageoptionaldoubleMaxHealthyPercentageoptional*float64 #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 #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 #minCapacityoptionalnumbermin_capacityoptionalint | floatminCapacityoptionalNumberMinCapacityoptionaldoubleMinCapacityoptional*float64 = 1 #minHealthyPercentageoptionalnumbermin_healthy_percentageoptionalint | floatminHealthyPercentageoptionalNumberMinHealthyPercentageoptionaldoubleMinHealthyPercentageoptional*float64 #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 #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 #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 #Default: No fleet change notifications will be sent.
requireImdsv2optionalbooleanrequire_imdsv2optionalboolrequireImdsv2optionalBooleanRequireImdsv2optionalboolRequireImdsv2optional*bool = false #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
const role = new iam.Role(this, 'MyRole', {
assumedBy: new iam.ServicePrincipal('ec2.amazonaws.com')
});
securityGroupoptionalISecurityGroupsecurity_groupoptionalISecurityGroupsecurityGroupoptionalISecurityGroupSecurityGroupoptionalISecurityGroupSecurityGroupoptionalISecurityGroup #Default: A SecurityGroup will be created if none is specified.
launchTemplate and mixedInstancesPolicy must not be specified when this property is specified
signalsoptionalSignalssignalsoptionalSignalssignalsoptionalSignalsSignalsoptionalSignalsSignalsoptionalSignals #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:
spotPriceoptionalstringspot_priceoptionalstrspotPriceoptionalStringSpotPriceoptionalstringSpotPriceoptional*string = none #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 #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` #The policies are executed in the order that you list them.
terminationPolicyCustomLambdaFunctionArnoptionalstringtermination_policy_custom_lambda_function_arnoptionalstrterminationPolicyCustomLambdaFunctionArnoptionalStringTerminationPolicyCustomLambdaFunctionArnoptionalstringTerminationPolicyCustomLambdaFunctionArnoptional*string #Default: No lambda function Arn will be supplied
This property must be specified if the TerminationPolicy.CUSTOM_LAMBDA_FUNCTION is used.
updatePolicyoptionalUpdatePolicyupdate_policyoptionalUpdatePolicyupdatePolicyoptionalUpdatePolicyUpdatePolicyoptionalUpdatePolicyUpdatePolicyoptionalUpdatePolicy #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 #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
vpcSubnetsoptionalSubnetSelectionvpc_subnetsoptionalSubnetSelectionvpcSubnetsoptionalSubnetSelectionVpcSubnetsoptionalSubnetSelectionVpcSubnetsoptionalSubnetSelection #Default: All Private subnets.
Properties
autoScalingGroupArnstringauto_scaling_group_arnstrautoScalingGroupArnStringAutoScalingGroupArnstringAutoScalingGroupArn*string #autoScalingGroupNamestringauto_scaling_group_namestrautoScalingGroupNameStringAutoScalingGroupNamestringAutoScalingGroupName*string #autoScalingGroupRefAutoScalingGroupReferenceauto_scaling_group_refAutoScalingGroupReferenceautoScalingGroupRefAutoScalingGroupReferenceAutoScalingGroupRefAutoScalingGroupReferenceAutoScalingGroupRefAutoScalingGroupReference #connectionsConnectionsconnectionsConnectionsconnectionsConnectionsConnectionsConnectionsConnectionsConnections #envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironment #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 #maxInstanceLifetimemay be undefinedDurationmax_instance_lifetimemay be undefinedDurationmaxInstanceLifetimemay be undefinedDurationMaxInstanceLifetimemay be undefinedDurationMaxInstanceLifetimemay be undefinedDuration #osTypeOperatingSystemTypeos_typeOperatingSystemTypeosTypeOperatingSystemTypeOsTypeOperatingSystemTypeOsTypeOperatingSystemType #PROPERTY_INJECTION_IDstringPROPERTY_INJECTION_IDstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*string static #spotPricemay be undefinedstringspot_pricemay be undefinedstrspotPricemay be undefinedStringSpotPricemay be undefinedstringSpotPricemay be undefined*string #undefined indicates that this group uses on-demand capacity.
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 #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) #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) #addUserData(...commands: string[]): voiddef add_user_data(self, commands: str) -> Nonepublic void addUserData(String commands)public void AddUserData(string commands)func AddUserData(Commands *string) #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 #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) #notes
This does the following:
- Attaches the CloudFormation Init metadata to the AutoScalingGroup resource.
- Add commands to the UserData to run
cfn-initandcfn-signal. - Update the instance's CreationPolicy to wait for
cfn-initto 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) #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) #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 #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 #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) #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 #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 #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 #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 #protectNewInstancesFromScaleIn(): voiddef protect_new_instances_from_scale_in(self, ) -> Nonepublic void protectNewInstancesFromScaleIn()public void ProtectNewInstancesFromScaleIn()func ProtectNewInstancesFromScaleIn() #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 #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 #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 #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 #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 #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 #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 #toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string #with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct #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.