Skip to content
v2.275.0

CfnLaunchConfiguration L1 construct ​

The AWS::AutoScaling::LaunchConfiguration resource specifies the launch configuration that can be used by an Auto Scaling group to configure Amazon EC2 instances.

When you update the launch configuration for an Auto Scaling group, CloudFormation deletes that resource and creates a new launch configuration with the updated properties and a new name. Existing instances are not affected. To update existing instances when you update the AWS::AutoScaling::LaunchConfiguration resource, you can specify an UpdatePolicy attribute for the group. You can find sample update policies for rolling updates in Configure Amazon EC2 Auto Scaling resources .

Amazon EC2 Auto Scaling configures instances launched as part of an Auto Scaling group using either a launch template or a launch configuration. We strongly recommend that you do not use launch configurations. For more information, see Launch configurations in the Amazon EC2 Auto Scaling User Guide .

For help migrating from launch configurations to launch templates, see Migrate AWS CloudFormation stacks from launch configurations to launch templates in the Amazon EC2 Auto Scaling User Guide .

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_autoscaling as autoscaling } from 'aws-cdk-lib';
const cfnLaunchConfiguration = new autoscaling.CfnLaunchConfiguration(this, 'MyCfnLaunchConfiguration', {
  imageId: 'imageId',
  instanceType: 'instanceType',

  // the properties below are optional
  associatePublicIpAddress: false,
  blockDeviceMappings: [{
    deviceName: 'deviceName',

    // the properties below are optional
    ebs: {
      deleteOnTermination: false,
      encrypted: false,
      iops: 123,
      snapshotId: 'snapshotId',
      throughput: 123,
      volumeSize: 123,
      volumeType: 'volumeType',
    },
    noDevice: false,
    virtualName: 'virtualName',
  }],
  classicLinkVpcId: 'classicLinkVpcId',
  classicLinkVpcSecurityGroups: ['classicLinkVpcSecurityGroups'],
  ebsOptimized: false,
  iamInstanceProfile: 'iamInstanceProfile',
  instanceId: 'instanceId',
  instanceMonitoring: false,
  kernelId: 'kernelId',
  keyName: 'keyName',
  launchConfigurationName: 'launchConfigurationName',
  metadataOptions: {
    httpEndpoint: 'httpEndpoint',
    httpPutResponseHopLimit: 123,
    httpTokens: 'httpTokens',
  },
  placementTenancy: 'placementTenancy',
  ramDiskId: 'ramDiskId',
  securityGroups: ['securityGroups'],
  spotPrice: 'spotPrice',
  userData: 'userData',
});
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_autoscaling as autoscaling

cfn_launch_configuration = autoscaling.CfnLaunchConfiguration(self, "MyCfnLaunchConfiguration",
    image_id="imageId",
    instance_type="instanceType",

    # the properties below are optional
    associate_public_ip_address=False,
    block_device_mappings=[autoscaling.CfnLaunchConfiguration.BlockDeviceMappingProperty(
        device_name="deviceName",

        # the properties below are optional
        ebs=autoscaling.CfnLaunchConfiguration.BlockDeviceProperty(
            delete_on_termination=False,
            encrypted=False,
            iops=123,
            snapshot_id="snapshotId",
            throughput=123,
            volume_size=123,
            volume_type="volumeType"
        ),
        no_device=False,
        virtual_name="virtualName"
    )],
    classic_link_vpc_id="classicLinkVpcId",
    classic_link_vpc_security_groups=["classicLinkVpcSecurityGroups"],
    ebs_optimized=False,
    iam_instance_profile="iamInstanceProfile",
    instance_id="instanceId",
    instance_monitoring=False,
    kernel_id="kernelId",
    key_name="keyName",
    launch_configuration_name="launchConfigurationName",
    metadata_options=autoscaling.CfnLaunchConfiguration.MetadataOptionsProperty(
        http_endpoint="httpEndpoint",
        http_put_response_hop_limit=123,
        http_tokens="httpTokens"
    ),
    placement_tenancy="placementTenancy",
    ram_disk_id="ramDiskId",
    security_groups=["securityGroups"],
    spot_price="spotPrice",
    user_data="userData"
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.autoscaling.*;

CfnLaunchConfiguration cfnLaunchConfiguration = CfnLaunchConfiguration.Builder.create(this, "MyCfnLaunchConfiguration")
        .imageId("imageId")
        .instanceType("instanceType")

        // the properties below are optional
        .associatePublicIpAddress(false)
        .blockDeviceMappings(List.of(BlockDeviceMappingProperty.builder()
                .deviceName("deviceName")

                // the properties below are optional
                .ebs(BlockDeviceProperty.builder()
                        .deleteOnTermination(false)
                        .encrypted(false)
                        .iops(123)
                        .snapshotId("snapshotId")
                        .throughput(123)
                        .volumeSize(123)
                        .volumeType("volumeType")
                        .build())
                .noDevice(false)
                .virtualName("virtualName")
                .build()))
        .classicLinkVpcId("classicLinkVpcId")
        .classicLinkVpcSecurityGroups(List.of("classicLinkVpcSecurityGroups"))
        .ebsOptimized(false)
        .iamInstanceProfile("iamInstanceProfile")
        .instanceId("instanceId")
        .instanceMonitoring(false)
        .kernelId("kernelId")
        .keyName("keyName")
        .launchConfigurationName("launchConfigurationName")
        .metadataOptions(MetadataOptionsProperty.builder()
                .httpEndpoint("httpEndpoint")
                .httpPutResponseHopLimit(123)
                .httpTokens("httpTokens")
                .build())
        .placementTenancy("placementTenancy")
        .ramDiskId("ramDiskId")
        .securityGroups(List.of("securityGroups"))
        .spotPrice("spotPrice")
        .userData("userData")
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.AutoScaling;

var cfnLaunchConfiguration = new CfnLaunchConfiguration(this, "MyCfnLaunchConfiguration", new CfnLaunchConfigurationProps {
    ImageId = "imageId",
    InstanceType = "instanceType",

    // the properties below are optional
    AssociatePublicIpAddress = false,
    BlockDeviceMappings = new [] { new BlockDeviceMappingProperty {
        DeviceName = "deviceName",

        // the properties below are optional
        Ebs = new BlockDeviceProperty {
            DeleteOnTermination = false,
            Encrypted = false,
            Iops = 123,
            SnapshotId = "snapshotId",
            Throughput = 123,
            VolumeSize = 123,
            VolumeType = "volumeType"
        },
        NoDevice = false,
        VirtualName = "virtualName"
    } },
    ClassicLinkVpcId = "classicLinkVpcId",
    ClassicLinkVpcSecurityGroups = new [] { "classicLinkVpcSecurityGroups" },
    EbsOptimized = false,
    IamInstanceProfile = "iamInstanceProfile",
    InstanceId = "instanceId",
    InstanceMonitoring = false,
    KernelId = "kernelId",
    KeyName = "keyName",
    LaunchConfigurationName = "launchConfigurationName",
    MetadataOptions = new MetadataOptionsProperty {
        HttpEndpoint = "httpEndpoint",
        HttpPutResponseHopLimit = 123,
        HttpTokens = "httpTokens"
    },
    PlacementTenancy = "placementTenancy",
    RamDiskId = "ramDiskId",
    SecurityGroups = new [] { "securityGroups" },
    SpotPrice = "spotPrice",
    UserData = "userData"
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

cfnLaunchConfiguration := awscdk.Aws_autoscaling.NewCfnLaunchConfiguration(this, jsii.String("MyCfnLaunchConfiguration"), &CfnLaunchConfigurationProps{
	ImageId: jsii.String("imageId"),
	InstanceType: jsii.String("instanceType"),

	// the properties below are optional
	AssociatePublicIpAddress: jsii.Boolean(false),
	BlockDeviceMappings: []interface{}{
		&BlockDeviceMappingProperty{
			DeviceName: jsii.String("deviceName"),

			// the properties below are optional
			Ebs: &BlockDeviceProperty{
				DeleteOnTermination: jsii.Boolean(false),
				Encrypted: jsii.Boolean(false),
				Iops: jsii.Number(123),
				SnapshotId: jsii.String("snapshotId"),
				Throughput: jsii.Number(123),
				VolumeSize: jsii.Number(123),
				VolumeType: jsii.String("volumeType"),
			},
			NoDevice: jsii.Boolean(false),
			VirtualName: jsii.String("virtualName"),
		},
	},
	ClassicLinkVpcId: jsii.String("classicLinkVpcId"),
	ClassicLinkVpcSecurityGroups: []*string{
		jsii.String("classicLinkVpcSecurityGroups"),
	},
	EbsOptimized: jsii.Boolean(false),
	IamInstanceProfile: jsii.String("iamInstanceProfile"),
	InstanceId: jsii.String("instanceId"),
	InstanceMonitoring: jsii.Boolean(false),
	KernelId: jsii.String("kernelId"),
	KeyName: jsii.String("keyName"),
	LaunchConfigurationName: jsii.String("launchConfigurationName"),
	MetadataOptions: &MetadataOptionsProperty{
		HttpEndpoint: jsii.String("httpEndpoint"),
		HttpPutResponseHopLimit: jsii.Number(123),
		HttpTokens: jsii.String("httpTokens"),
	},
	PlacementTenancy: jsii.String("placementTenancy"),
	RamDiskId: jsii.String("ramDiskId"),
	SecurityGroups: []interface{}{
		jsii.String("securityGroups"),
	},
	SpotPrice: jsii.String("spotPrice"),
	UserData: jsii.String("userData"),
})

Initializer ​

ts
new CfnLaunchConfiguration(scope: Construct, id: string, props: CfnLaunchConfigurationProps)
python
CfnLaunchConfiguration(scope: Construct, id: str, props: CfnLaunchConfigurationProps)
java
new CfnLaunchConfiguration(Construct scope, String id, CfnLaunchConfigurationProps props)
csharp
new CfnLaunchConfiguration(Construct scope, string id, CfnLaunchConfigurationProps props)
go
NewCfnLaunchConfiguration(Scope Construct, Id *string, Props CfnLaunchConfigurationProps)

Construct Props ​

associatePublicIpAddressoptionalboolean | IResolvableassociate_public_ip_addressoptionaltyping.Union[bool, IResolvable]associatePublicIpAddressoptionalBooleanAssociatePublicIpAddressoptionalboolAssociatePublicIpAddressoptionalinterface{}#
Specifies whether to assign a public IPv4 address to the group's instances.
notes

If the instance is launched into a default subnet, the default is to assign a public IPv4 address, unless you disabled the option to assign a public IPv4 address on the subnet. If the instance is launched into a nondefault subnet, the default is not to assign a public IPv4 address, unless you enabled the option to assign a public IPv4 address on the subnet.

If you specify true , each instance in the Auto Scaling group receives a unique public IPv4 address. For more information, see Provide network connectivity for your Auto Scaling instances using Amazon VPC in the Amazon EC2 Auto Scaling User Guide .

If you specify this property, you must specify at least one subnet for VPCZoneIdentifier when you create your group.

blockDeviceMappingsoptionalIResolvable | IResolvable | CfnLaunchConfiguration.BlockDeviceMappingProperty[]block_device_mappingsoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, BlockDeviceMappingProperty]]]blockDeviceMappingsoptionalIResolvableBlockDeviceMappingsoptionalIResolvableBlockDeviceMappingsoptionalinterface{}#
The block device mapping entries that define the block devices to attach to the instances at launch.
notes

By default, the block devices specified in the block device mapping for the AMI are used. For more information, see Block device mappings in the Amazon EC2 User Guide .

classicLinkVpcIdoptionalstringclassic_link_vpc_idoptionalstrclassicLinkVpcIdoptionalStringClassicLinkVpcIdoptionalstringClassicLinkVpcIdoptional*string#
Available for backward compatibility.
classicLinkVpcSecurityGroupsoptionalstring[]classic_link_vpc_security_groupsoptionaltyping.List[str]classicLinkVpcSecurityGroupsoptionalList<String>ClassicLinkVpcSecurityGroupsoptionalstring[]ClassicLinkVpcSecurityGroupsoptional*[]*string#
Available for backward compatibility.
ebsOptimizedoptionalboolean | IResolvableebs_optimizedoptionaltyping.Union[bool, IResolvable]ebsOptimizedoptionalBooleanEbsOptimizedoptionalboolEbsOptimizedoptionalinterface{}#
Specifies whether the launch configuration is optimized for EBS I/O ( `true` ) or not ( `false` ).
notes

The optimization provides dedicated throughput to Amazon EBS and an optimized configuration stack to provide optimal I/O performance. This optimization is not available with all instance types. Additional fees are incurred when you enable EBS optimization for an instance type that is not EBS-optimized by default. For more information, see Amazon EBS-optimized instances in the Amazon EC2 User Guide .

The default value is false .

iamInstanceProfileoptionalstring | IInstanceProfileRefiam_instance_profileoptionaltyping.Union[str, IInstanceProfileRef]iamInstanceProfileoptionalStringIamInstanceProfileoptionalstringIamInstanceProfileoptionalinterface{}#
The name or the Amazon Resource Name (ARN) of the instance profile associated with the IAM role for the instance.
notes

The instance profile contains the IAM role. For more information, see IAM role for applications that run on Amazon EC2 instances in the Amazon EC2 Auto Scaling User Guide .

imageIdstringimage_idstrimageIdStringImageIdstringImageId*stringrequired#
The ID of the Amazon Machine Image (AMI) that was assigned during registration.

For more information, see Find a Linux AMI in the Amazon EC2 User Guide .

If you specify InstanceId , an ImageId is not required.

instanceIdoptionalstringinstance_idoptionalstrinstanceIdoptionalStringInstanceIdoptionalstringInstanceIdoptional*string#
The ID of the Amazon EC2 instance to use to create the launch configuration.
notes

When you use an instance to create a launch configuration, all properties are derived from the instance with the exception of BlockDeviceMapping and AssociatePublicIpAddress . You can override any properties from the instance by specifying them in the launch configuration.

instanceMonitoringoptionalboolean | IResolvableinstance_monitoringoptionaltyping.Union[bool, IResolvable]instanceMonitoringoptionalBooleanInstanceMonitoringoptionalboolInstanceMonitoringoptionalinterface{}#
Controls whether instances in this group are launched with detailed ( `true` ) or basic ( `false` ) monitoring.
notes

The default value is true (enabled).

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. For more information, see Configure monitoring for Auto Scaling instances in the Amazon EC2 Auto Scaling User Guide .

instanceTypestringinstance_typestrinstanceTypeStringInstanceTypestringInstanceType*stringrequired#
Specifies the instance type of the EC2 instance.
notes

For information about available instance types, see Available instance types in the Amazon EC2 User Guide .

If you specify InstanceId , an InstanceType is not required.

kernelIdoptionalstringkernel_idoptionalstrkernelIdoptionalStringKernelIdoptionalstringKernelIdoptional*string#
The ID of the kernel associated with the AMI.

We recommend that you use PV-GRUB instead of kernels and RAM disks. For more information, see User provided kernels in the Amazon EC2 User Guide .

keyNameoptionalstringkey_nameoptionalstrkeyNameoptionalStringKeyNameoptionalstringKeyNameoptional*string#
The name of the key pair.

For more information, see Amazon EC2 key pairs and Amazon EC2 instances in the Amazon EC2 User Guide .

launchConfigurationNameoptionalstringlaunch_configuration_nameoptionalstrlaunchConfigurationNameoptionalStringLaunchConfigurationNameoptionalstringLaunchConfigurationNameoptional*string#
The name of the launch configuration.

This name must be unique per Region per account.

metadataOptionsoptionalIResolvable | CfnLaunchConfiguration.MetadataOptionsPropertymetadata_optionsoptionaltyping.Union[IResolvable, MetadataOptionsProperty]metadataOptionsoptionalIResolvableMetadataOptionsoptionalIResolvableMetadataOptionsoptionalinterface{}#
The metadata options for the instances.

For more information, see Configure the instance metadata options in the Amazon EC2 Auto Scaling User Guide .

placementTenancyoptionalstringplacement_tenancyoptionalstrplacementTenancyoptionalStringPlacementTenancyoptionalstringPlacementTenancyoptional*string#
The tenancy of the instance, either `default` or `dedicated` .
notes

An instance with dedicated tenancy runs on isolated, single-tenant hardware and can only be launched into a VPC. To launch dedicated instances into a shared tenancy VPC (a VPC with the instance placement tenancy attribute set to default ), you must set the value of this property to dedicated .

If you specify PlacementTenancy , you must specify at least one subnet for VPCZoneIdentifier when you create your group.

Valid values: default | dedicated

ramDiskIdoptionalstringram_disk_idoptionalstrramDiskIdoptionalStringRamDiskIdoptionalstringRamDiskIdoptional*string#
The ID of the RAM disk to select.

We recommend that you use PV-GRUB instead of kernels and RAM disks. For more information, see User provided kernels in the Amazon EC2 User Guide .

securityGroupsoptionalstring | ISecurityGroupRef[]security_groupsoptionaltyping.List[typing.Union[str, ISecurityGroupRef]]securityGroupsoptionalList<String>SecurityGroupsoptionalstring[]SecurityGroupsoptional*[]interface{}#
A list that contains the security groups to assign to the instances in the Auto Scaling group.
notes

The list can contain both the IDs of existing security groups and references to SecurityGroup resources created in the template.

For more information, see Control traffic to resources using security groups in the Amazon Virtual Private Cloud User Guide .

spotPriceoptionalstringspot_priceoptionalstrspotPriceoptionalStringSpotPriceoptionalstringSpotPriceoptional*string#
The maximum hourly price to be paid for any Spot Instance launched to fulfill the request.
notes

Spot Instances are launched when the price you specify exceeds the current Spot price. For more information, see Request Spot Instances for fault-tolerant and flexible applications in the Amazon EC2 Auto Scaling User Guide .

Valid Range: Minimum value of 0.001

When you change your maximum price by creating a new launch configuration, running instances will continue to run as long as the maximum price for those running instances is higher than the current Spot price.

userDataoptionalstringuser_dataoptionalstruserDataoptionalStringUserDataoptionalstringUserDataoptional*string#
The Base64-encoded user data to make available to the launched EC2 instances.

For more information, see Instance metadata and user data in the Amazon EC2 User Guide for Linux Instances .

Properties ​

associatePublicIpAddressmay be undefinedboolean | IResolvableassociate_public_ip_addressmay be undefinedtyping.Union[bool, IResolvable]associatePublicIpAddressmay be undefinedBooleanAssociatePublicIpAddressmay be undefinedboolAssociatePublicIpAddressmay be undefinedinterface{}#
Specifies whether to assign a public IPv4 address to the group's instances.
blockDeviceMappingsmay be undefinedIResolvable | IResolvable | CfnLaunchConfiguration.BlockDeviceMappingProperty[]block_device_mappingsmay be undefinedtyping.Union[IResolvable, typing.List[typing.Union[IResolvable, BlockDeviceMappingProperty]]]blockDeviceMappingsmay be undefinedIResolvableBlockDeviceMappingsmay be undefinedIResolvableBlockDeviceMappingsmay be undefinedinterface{}#
The block device mapping entries that define the block devices to attach to the instances at launch.
CFN_RESOURCE_TYPE_NAMEstringcfn_resource_type_namestrCFN_RESOURCE_TYPE_NAMEStringCFN_RESOURCE_TYPE_NAMEstringCFN_RESOURCE_TYPE_NAME*stringstatic#
The CloudFormation resource type name for this resource class.
Options for this resource, such as condition, update policy etc.
cfnResourceTypestringcfn_resource_typestrcfnResourceTypeStringCfnResourceTypestringCfnResourceType*string#
AWS resource type.
classicLinkVpcIdmay be undefinedstringclassic_link_vpc_idmay be undefinedstrclassicLinkVpcIdmay be undefinedStringClassicLinkVpcIdmay be undefinedstringClassicLinkVpcIdmay be undefined*string#
Available for backward compatibility.
classicLinkVpcSecurityGroupsmay be undefinedstring[]classic_link_vpc_security_groupsmay be undefinedtyping.List[str]classicLinkVpcSecurityGroupsmay be undefinedList<String>ClassicLinkVpcSecurityGroupsmay be undefinedstring[]ClassicLinkVpcSecurityGroupsmay be undefined*[]*string#
Available for backward compatibility.
creationStackstring[]creation_stacktyping.List[str]creationStackList<String>CreationStackstring[]CreationStack*[]*string#
ebsOptimizedmay be undefinedboolean | IResolvableebs_optimizedmay be undefinedtyping.Union[bool, IResolvable]ebsOptimizedmay be undefinedBooleanEbsOptimizedmay be undefinedboolEbsOptimizedmay be undefinedinterface{}#
Specifies whether the launch configuration is optimized for EBS I/O ( `true` ) or not ( `false` ).
iamInstanceProfilemay be undefinedstringiam_instance_profilemay be undefinedstriamInstanceProfilemay be undefinedStringIamInstanceProfilemay be undefinedstringIamInstanceProfilemay be undefined*string#
The name or the Amazon Resource Name (ARN) of the instance profile associated with the IAM role for the instance.
imageIdstringimage_idstrimageIdStringImageIdstringImageId*string#
The ID of the Amazon Machine Image (AMI) that was assigned during registration.
instanceIdmay be undefinedstringinstance_idmay be undefinedstrinstanceIdmay be undefinedStringInstanceIdmay be undefinedstringInstanceIdmay be undefined*string#
The ID of the Amazon EC2 instance to use to create the launch configuration.
instanceMonitoringmay be undefinedboolean | IResolvableinstance_monitoringmay be undefinedtyping.Union[bool, IResolvable]instanceMonitoringmay be undefinedBooleanInstanceMonitoringmay be undefinedboolInstanceMonitoringmay be undefinedinterface{}#
Controls whether instances in this group are launched with detailed ( `true` ) or basic ( `false` ) monitoring.
instanceTypestringinstance_typestrinstanceTypeStringInstanceTypestringInstanceType*string#
Specifies the instance type of the EC2 instance.
kernelIdmay be undefinedstringkernel_idmay be undefinedstrkernelIdmay be undefinedStringKernelIdmay be undefinedstringKernelIdmay be undefined*string#
The ID of the kernel associated with the AMI.
keyNamemay be undefinedstringkey_namemay be undefinedstrkeyNamemay be undefinedStringKeyNamemay be undefinedstringKeyNamemay be undefined*string#
The name of the key pair.
launchConfigurationNamemay be undefinedstringlaunch_configuration_namemay be undefinedstrlaunchConfigurationNamemay be undefinedStringLaunchConfigurationNamemay be undefinedstringLaunchConfigurationNamemay be undefined*string#
The name of the launch configuration.
launchConfigurationRefLaunchConfigurationReferencelaunch_configuration_refLaunchConfigurationReferencelaunchConfigurationRefLaunchConfigurationReferenceLaunchConfigurationRefLaunchConfigurationReferenceLaunchConfigurationRefLaunchConfigurationReference#
A reference to a LaunchConfiguration resource.
logicalIdstringlogical_idstrlogicalIdStringLogicalIdstringLogicalId*string#
The logical ID for this CloudFormation stack element.

The logical ID of the element is calculated from the path of the resource node in the construct tree.

To override this value, use overrideLogicalId(newLogicalId).

metadataOptionsmay be undefinedIResolvable | CfnLaunchConfiguration.MetadataOptionsPropertymetadata_optionsmay be undefinedtyping.Union[IResolvable, MetadataOptionsProperty]metadataOptionsmay be undefinedIResolvableMetadataOptionsmay be undefinedIResolvableMetadataOptionsmay be undefinedinterface{}#
The metadata options for the instances.
nodeNodenodeNodenodeNodeNodeNodeNodeNode#
The tree node.
placementTenancymay be undefinedstringplacement_tenancymay be undefinedstrplacementTenancymay be undefinedStringPlacementTenancymay be undefinedstringPlacementTenancymay be undefined*string#
The tenancy of the instance, either `default` or `dedicated` .
ramDiskIdmay be undefinedstringram_disk_idmay be undefinedstrramDiskIdmay be undefinedStringRamDiskIdmay be undefinedstringRamDiskIdmay be undefined*string#
The ID of the RAM disk to select.
refstringrefstrrefStringRefstringRef*string#
Return a string that will be resolved to a CloudFormation `{ Ref }` for this element.

If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through Lazy.any({ produce: resource.ref }).

securityGroupsmay be undefinedstring[]security_groupsmay be undefinedtyping.List[str]securityGroupsmay be undefinedList<String>SecurityGroupsmay be undefinedstring[]SecurityGroupsmay be undefined*[]*string#
A list that contains the security groups to assign to the instances in the Auto Scaling group.
spotPricemay be undefinedstringspot_pricemay be undefinedstrspotPricemay be undefinedStringSpotPricemay be undefinedstringSpotPricemay be undefined*string#
The maximum hourly price to be paid for any Spot Instance launched to fulfill the request.
stackStackstackStackstackStackStackStackStackStack#
The stack in which this element is defined.

CfnElements must be defined within a stack scope (directly or indirectly).

userDatamay be undefinedstringuser_datamay be undefinedstruserDatamay be undefinedStringUserDatamay be undefinedstringUserDatamay be undefined*string#
The Base64-encoded user data to make available to the launched EC2 instances.

Methods ​

addDeletionOverride(path: string): voiddef add_deletion_override(self, path: str) -> Nonepublic void addDeletionOverride(String path)public void AddDeletionOverride(string path)func AddDeletionOverride(Path *string)#
Syntactic sugar for `addOverride(path, undefined)`.
1 parameter

Parameters

  • pathpathpathpathPath — The path of the value to delete.
addDependency(target: CfnResource): voiddef add_dependency(self, target: CfnResource) -> Nonepublic void addDependency(CfnResource target)public void AddDependency(CfnResource target)func AddDependency(Target CfnResource)deprecated#
Use `addResourceDependency` instead.

This method has been renamed to addResourceDependency to more clearly set it apart from construct.node.addDependency. See the documentation of that function for more details.

addDependsOn(target: CfnResource): voiddef add_depends_on(self, target: CfnResource) -> Nonepublic void addDependsOn(CfnResource target)public void AddDependsOn(CfnResource target)func AddDependsOn(Target CfnResource)deprecated#
Use `addResourceDependency` instead.
notes

This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.

This method has been renamed to addResourceDependency, which makes it more clear that this method operates at a different level from the construct-level construct.node.addDependency() mechanism.

addMetadata(key: string, value: any): voiddef add_metadata(self, key: str, value: Any) -> Nonepublic void addMetadata(String key, Object value)public void AddMetadata(string key, object value)func AddMetadata(Key *string, Value interface{})#
Add a value to the CloudFormation Resource Metadata.
addOverride(path: string, value: any): voiddef add_override(self, path: str, value: Any) -> Nonepublic void addOverride(String path, Object value)public void AddOverride(string path, object value)func AddOverride(Path *string, Value interface{})#
Adds an override to the synthesized CloudFormation resource.
notes · 2 parameters

To add a property override, either use addPropertyOverride or prefix path with "Properties." (i.e. Properties.TopicName).

If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

For example,

typescript
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']);
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.1.ProjectionType', 'INCLUDE');

would add the overrides

json
"Properties": {
  "GlobalSecondaryIndexes": [
    {
      "Projection": {
        "NonKeyAttributes": [ "myattribute" ]
        ...
      }
      ...
    },
    {
      "ProjectionType": "INCLUDE"
      ...
    },
  ]
  ...
}

The value argument to addOverride will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.

Parameters

  • pathpathpathpathPath — - The path of the property, you can use dot notation to override values in complex types.
  • valuevaluevaluevalueValue — - The value.
addPropertyDeletionOverride(propertyPath: string): voiddef add_property_deletion_override(self, property_path: str) -> Nonepublic void addPropertyDeletionOverride(String propertyPath)public void AddPropertyDeletionOverride(string propertyPath)func AddPropertyDeletionOverride(PropertyPath *string)#
Adds an override that deletes the value of a property from the resource definition.
1 parameter

Parameters

  • propertyPathproperty_pathpropertyPathpropertyPathPropertyPath — The path to the property.
addPropertyOverride(propertyPath: string, value: any): voiddef add_property_override(self, property_path: str, value: Any) -> Nonepublic void addPropertyOverride(String propertyPath, Object value)public void AddPropertyOverride(string propertyPath, object value)func AddPropertyOverride(PropertyPath *string, Value interface{})#
Adds an override to a resource property.

Syntactic sugar for addOverride("Properties.<...>", value).

2 parameters

Parameters

  • propertyPathproperty_pathpropertyPathpropertyPathPropertyPath — The path of the property.
  • valuevaluevaluevalueValue — The value.
addResourceDependency(target: CfnResource, reason?: string): voiddef add_resource_dependency(self, target: CfnResource, reason: typing.Optional[str] = None) -> Nonepublic void addResourceDependency(CfnResource target, String reason)public void AddResourceDependency(CfnResource target, string? reason = null)func AddResourceDependency(Target CfnResource, Reason *string)#
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
notes

This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.

This method only adds dependencies between L1 resources. If you are looking for a generic construct-to-construct dependency mechanism that works for all constructs including L2s, use construct.node.addDependency instead.

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)#
Sets the cross-stack reference strength for this resource.

When set, any cross-stack reference to this resource will use the specified strength instead of the global default from the consuming stack's context.

1 parameter

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy?: RemovalPolicy, options?: RemovalPolicyOptions): voiddef apply_removal_policy(self, policy: typing.Optional[RemovalPolicy] = None, options: typing.Optional[RemovalPolicyOptions] = None) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy, RemovalPolicyOptions options)public void ApplyRemovalPolicy(RemovalPolicy? policy = null, RemovalPolicyOptions? options = null)func ApplyRemovalPolicy(Policy RemovalPolicy, Options RemovalPolicyOptions)#
Sets the deletion policy of the resource based on the removal policy specified.
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). In some cases, a snapshot can be taken of the resource prior to deletion (RemovalPolicy.SNAPSHOT). A list of resources that support this policy can be found in the following link:

cfnPropertyName(cdkPropertyName: string): stringdef cfn_property_name(self, cdk_property_name: str) -> strpublic String cfnPropertyName(String cdkPropertyName)public string CfnPropertyName(string cdkPropertyName)func CfnPropertyName(CdkPropertyName *string) *string#
getAtt(attributeName: string, typeHint?: ResolutionTypeHint): Referencedef get_att(self, attribute_name: str, type_hint: typing.Optional[ResolutionTypeHint] = None) -> Referencepublic Reference getAtt(String attributeName, ResolutionTypeHint typeHint)public Reference GetAtt(string attributeName, ResolutionTypeHint? typeHint = null)func GetAtt(AttributeName *string, TypeHint ResolutionTypeHint) Reference#
Returns a token for an runtime attribute of this resource.

Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility in case there is no generated attribute.

1 parameter

Parameters

  • attributeNameattribute_nameattributeNameattributeNameAttributeName — The name of the attribute.
getMetadata(key: string): anydef get_metadata(self, key: str) -> Anypublic Object getMetadata(String key)public object GetMetadata(string key)func GetMetadata(Key *string) interface{}#
Retrieve a value value from the CloudFormation Resource Metadata.
inspect(inspector: TreeInspector): voiddef inspect(self, inspector: TreeInspector) -> Nonepublic void inspect(TreeInspector inspector)public void Inspect(TreeInspector inspector)func Inspect(Inspector TreeInspector)#
Examines the CloudFormation resource and discloses attributes.
1 parameter

Parameters

  • inspectorinspectorinspectorinspectorInspector — tree inspector to collect and process attributes.
isCfnElement(x: any): boolean@staticmethod def is_cfn_element(x: Any) -> boolpublic static Boolean isCfnElement(Object x)public static bool IsCfnElement(object x)func IsCfnElement(X interface{}) *boolstatic#
Returns `true` if a construct is a stack element (i.e. part of the synthesized cloudformation template).

Uses duck-typing instead of instanceof to allow stack elements from different versions of this library to be included in the same stack.

returns

Returns: The construct as a stack element or undefined if it is not a stack element.

isCfnLaunchConfiguration(x: any): boolean@staticmethod def is_cfn_launch_configuration(x: Any) -> boolpublic static Boolean isCfnLaunchConfiguration(Object x)public static bool IsCfnLaunchConfiguration(object x)func IsCfnLaunchConfiguration(X interface{}) *boolstatic#
Checks whether the given object is a CfnLaunchConfiguration.
isCfnResource(x: any): boolean@staticmethod def is_cfn_resource(x: Any) -> boolpublic static Boolean isCfnResource(Object x)public static bool IsCfnResource(object x)func IsCfnResource(X interface{}) *boolstatic#
Check whether the given object is a CfnResource.
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{}) *boolstatic#
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.

obtainDependencies(): Stack | CfnResource[]def obtain_dependencies(self, ) -> typing.List[typing.Union[Stack, CfnResource]]public List<Stack> obtainDependencies()public Stack[] ObtainDependencies()func ObtainDependencies() *[]interface{}#
Retrieves an array of resources and stacks this resource depends on.

For resources depended on directly, returns the CfnResource object. For dependencies on other stacks, returns the Stack object. The order of the array is not guaranteed.

overrideLogicalId(newLogicalId: string): voiddef override_logical_id(self, new_logical_id: str) -> Nonepublic void overrideLogicalId(String newLogicalId)public void OverrideLogicalId(string newLogicalId)func OverrideLogicalId(NewLogicalId *string)#
Overrides the auto-generated logical ID with a specific ID.
1 parameter

Parameters

  • newLogicalIdnew_logical_idnewLogicalIdnewLogicalIdNewLogicalId — The new logical ID to use for this stack element.
removeDependency(target: CfnResource): voiddef remove_dependency(self, target: CfnResource) -> Nonepublic void removeDependency(CfnResource target)public void RemoveDependency(CfnResource target)func RemoveDependency(Target CfnResource)deprecated#
Use `removeResourceDependency` instead

This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.

removeResourceDependency(target: CfnResource): voiddef remove_resource_dependency(self, target: CfnResource) -> Nonepublic void removeResourceDependency(CfnResource target)public void RemoveResourceDependency(CfnResource target)func RemoveResourceDependency(Target CfnResource)#
Indicates that this resource no longer depends on another resource.

This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.

replaceDependency(target: CfnResource, newTarget: CfnResource): voiddef replace_dependency(self, target: CfnResource, new_target: CfnResource) -> Nonepublic void replaceDependency(CfnResource target, CfnResource newTarget)public void ReplaceDependency(CfnResource target, CfnResource newTarget)func ReplaceDependency(Target CfnResource, NewTarget CfnResource)#
Replaces one dependency with another.
2 parameters

Parameters

  • targettargettargettargetTarget — The dependency to replace.
  • newTargetnew_targetnewTargetnewTargetNewTarget — The new dependency to add.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
returns

Returns: a string representation of this resource

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.