class CfnLaunchConfiguration (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.AutoScaling.CfnLaunchConfiguration |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsautoscaling#CfnLaunchConfiguration |
![]() | software.amazon.awscdk.services.autoscaling.CfnLaunchConfiguration |
![]() | aws_cdk.aws_autoscaling.CfnLaunchConfiguration |
![]() | aws-cdk-lib » aws_autoscaling » CfnLaunchConfiguration |
Implements
IConstruct
, IDependable
, IInspectable
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
// 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',
});
Initializer
new CfnLaunchConfiguration(scope: Construct, id: string, props: CfnLaunchConfigurationProps)
Parameters
- scope
Construct
— Scope in which this resource is defined. - id
string
— Construct identifier for this resource (unique in its scope). - props
Cfn
— Resource properties.Launch Configuration Props
Construct Props
Name | Type | Description |
---|---|---|
image | string | The ID of the Amazon Machine Image (AMI) that was assigned during registration. |
instance | string | Specifies the instance type of the EC2 instance. |
associate | boolean | IResolvable | Specifies whether to assign a public IPv4 address to the group's instances. |
block | IResolvable | IResolvable | Block [] | The block device mapping entries that define the block devices to attach to the instances at launch. |
classic | string | Available for backward compatibility. |
classic | string[] | Available for backward compatibility. |
ebs | boolean | IResolvable | Specifies whether the launch configuration is optimized for EBS I/O ( true ) or not ( false ). |
iam | string | The name or the Amazon Resource Name (ARN) of the instance profile associated with the IAM role for the instance. |
instance | string | The ID of the Amazon EC2 instance to use to create the launch configuration. |
instance | boolean | IResolvable | Controls whether instances in this group are launched with detailed ( true ) or basic ( false ) monitoring. |
kernel | string | The ID of the kernel associated with the AMI. |
key | string | The name of the key pair. |
launch | string | The name of the launch configuration. |
metadata | IResolvable | Metadata | The metadata options for the instances. |
placement | string | The tenancy of the instance, either default or dedicated . |
ram | string | The ID of the RAM disk to select. |
security | string[] | A list that contains the security groups to assign to the instances in the Auto Scaling group. |
spot | string | The maximum hourly price to be paid for any Spot Instance launched to fulfill the request. |
user | string | The Base64-encoded user data to make available to the launched EC2 instances. |
imageId
Type:
string
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 for Linux Instances .
If you specify InstanceId
, an ImageId
is not required.
instanceType
Type:
string
Specifies the instance type of the EC2 instance.
For information about available instance types, see Available instance types in the Amazon EC2 User Guide for Linux Instances .
If you specify InstanceId
, an InstanceType
is not required.
associatePublicIpAddress?
Type:
boolean |
IResolvable
(optional)
Specifies whether to assign a public IPv4 address to the group's instances.
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.
blockDeviceMappings?
Type:
IResolvable
|
IResolvable
|
Block
[]
(optional)
The block device mapping entries that define the block devices to attach to the instances at launch.
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 for Linux Instances .
classicLinkVpcId?
Type:
string
(optional)
Available for backward compatibility.
classicLinkVpcSecurityGroups?
Type:
string[]
(optional)
Available for backward compatibility.
ebsOptimized?
Type:
boolean |
IResolvable
(optional)
Specifies whether the launch configuration is optimized for EBS I/O ( true
) or not ( false
).
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 for Linux Instances .
The default value is false
.
iamInstanceProfile?
Type:
string
(optional)
The name or the Amazon Resource Name (ARN) of the instance profile associated with the IAM role for the instance.
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 .
instanceId?
Type:
string
(optional)
The ID of the Amazon EC2 instance to use to create the launch configuration.
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.
instanceMonitoring?
Type:
boolean |
IResolvable
(optional)
Controls whether instances in this group are launched with detailed ( true
) or basic ( false
) monitoring.
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 .
kernelId?
Type:
string
(optional)
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 for Linux Instances .
keyName?
Type:
string
(optional)
The name of the key pair.
For more information, see Amazon EC2 key pairs and Amazon EC2 instances in the Amazon EC2 User Guide for Linux Instances .
launchConfigurationName?
Type:
string
(optional)
The name of the launch configuration.
This name must be unique per Region per account.
metadataOptions?
Type:
IResolvable
|
Metadata
(optional)
The metadata options for the instances.
For more information, see Configure the instance metadata options in the Amazon EC2 Auto Scaling User Guide .
placementTenancy?
Type:
string
(optional)
The tenancy of the instance, either default
or dedicated
.
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
ramDiskId?
Type:
string
(optional)
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 for Linux Instances .
securityGroups?
Type:
string[]
(optional)
A list that contains the security groups to assign to the instances in the Auto Scaling group.
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 .
spotPrice?
Type:
string
(optional)
The maximum hourly price 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 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.
userData?
Type:
string
(optional)
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
Name | Type | Description |
---|---|---|
cfn | ICfn | Options for this resource, such as condition, update policy etc. |
cfn | { [string]: any } | |
cfn | string | AWS resource type. |
creation | string[] | |
image | string | The ID of the Amazon Machine Image (AMI) that was assigned during registration. |
instance | string | Specifies the instance type of the EC2 instance. |
logical | string | The logical ID for this CloudFormation stack element. |
node | Node | The tree node. |
ref | string | Return a string that will be resolved to a CloudFormation { Ref } for this element. |
stack | Stack | The stack in which this element is defined. |
associate | boolean | IResolvable | Specifies whether to assign a public IPv4 address to the group's instances. |
block | IResolvable | IResolvable | Block [] | The block device mapping entries that define the block devices to attach to the instances at launch. |
classic | string | Available for backward compatibility. |
classic | string[] | Available for backward compatibility. |
ebs | boolean | IResolvable | Specifies whether the launch configuration is optimized for EBS I/O ( true ) or not ( false ). |
iam | string | The name or the Amazon Resource Name (ARN) of the instance profile associated with the IAM role for the instance. |
instance | string | The ID of the Amazon EC2 instance to use to create the launch configuration. |
instance | boolean | IResolvable | Controls whether instances in this group are launched with detailed ( true ) or basic ( false ) monitoring. |
kernel | string | The ID of the kernel associated with the AMI. |
key | string | The name of the key pair. |
launch | string | The name of the launch configuration. |
metadata | IResolvable | Metadata | The metadata options for the instances. |
placement | string | The tenancy of the instance, either default or dedicated . |
ram | string | The ID of the RAM disk to select. |
security | string[] | A list that contains the security groups to assign to the instances in the Auto Scaling group. |
spot | string | The maximum hourly price to be paid for any Spot Instance launched to fulfill the request. |
user | string | The Base64-encoded user data to make available to the launched EC2 instances. |
static CFN_RESOURCE_TYPE_NAME | string | The CloudFormation resource type name for this resource class. |
cfnOptions
Type:
ICfn
Options for this resource, such as condition, update policy etc.
cfnProperties
Type:
{ [string]: any }
cfnResourceType
Type:
string
AWS resource type.
creationStack
Type:
string[]
imageId
Type:
string
The ID of the Amazon Machine Image (AMI) that was assigned during registration.
instanceType
Type:
string
Specifies the instance type of the EC2 instance.
logicalId
Type:
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)
.
node
Type:
Node
The tree node.
ref
Type:
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 })
.
stack
Type:
Stack
The stack in which this element is defined.
CfnElements must be defined within a stack scope (directly or indirectly).
associatePublicIpAddress?
Type:
boolean |
IResolvable
(optional)
Specifies whether to assign a public IPv4 address to the group's instances.
blockDeviceMappings?
Type:
IResolvable
|
IResolvable
|
Block
[]
(optional)
The block device mapping entries that define the block devices to attach to the instances at launch.
classicLinkVpcId?
Type:
string
(optional)
Available for backward compatibility.
classicLinkVpcSecurityGroups?
Type:
string[]
(optional)
Available for backward compatibility.
ebsOptimized?
Type:
boolean |
IResolvable
(optional)
Specifies whether the launch configuration is optimized for EBS I/O ( true
) or not ( false
).
iamInstanceProfile?
Type:
string
(optional)
The name or the Amazon Resource Name (ARN) of the instance profile associated with the IAM role for the instance.
instanceId?
Type:
string
(optional)
The ID of the Amazon EC2 instance to use to create the launch configuration.
instanceMonitoring?
Type:
boolean |
IResolvable
(optional)
Controls whether instances in this group are launched with detailed ( true
) or basic ( false
) monitoring.
kernelId?
Type:
string
(optional)
The ID of the kernel associated with the AMI.
keyName?
Type:
string
(optional)
The name of the key pair.
launchConfigurationName?
Type:
string
(optional)
The name of the launch configuration.
metadataOptions?
Type:
IResolvable
|
Metadata
(optional)
The metadata options for the instances.
placementTenancy?
Type:
string
(optional)
The tenancy of the instance, either default
or dedicated
.
ramDiskId?
Type:
string
(optional)
The ID of the RAM disk to select.
securityGroups?
Type:
string[]
(optional)
A list that contains the security groups to assign to the instances in the Auto Scaling group.
spotPrice?
Type:
string
(optional)
The maximum hourly price to be paid for any Spot Instance launched to fulfill the request.
userData?
Type:
string
(optional)
The Base64-encoded user data to make available to the launched EC2 instances.
static CFN_RESOURCE_TYPE_NAME
Type:
string
The CloudFormation resource type name for this resource class.
Methods
Name | Description |
---|---|
add | Syntactic sugar for addOverride(path, undefined) . |
add | Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned. |
add | Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned. |
add | Add a value to the CloudFormation Resource Metadata. |
add | Adds an override to the synthesized CloudFormation resource. |
add | Adds an override that deletes the value of a property from the resource definition. |
add | Adds an override to a resource property. |
apply | Sets the deletion policy of the resource based on the removal policy specified. |
get | Returns a token for an runtime attribute of this resource. |
get | Retrieve a value value from the CloudFormation Resource Metadata. |
inspect(inspector) | Examines the CloudFormation resource and discloses attributes. |
obtain | Retrieves an array of resources this resource depends on. |
obtain | Get a shallow copy of dependencies between this resource and other resources in the same stack. |
override | Overrides the auto-generated logical ID with a specific ID. |
remove | Indicates that this resource no longer depends on another resource. |
replace | Replaces one dependency with another. |
to | Returns a string representation of this construct. |
protected render |
addDeletionOverride(path)
public addDeletionOverride(path: string): void
Parameters
- path
string
— The path of the value to delete.
Syntactic sugar for addOverride(path, undefined)
.
addDependency(target)
public addDependency(target: CfnResource): void
Parameters
- target
Cfn
Resource
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
addDependsOn(target)
public addDependsOn(target: CfnResource): void
⚠️ Deprecated: use addDependency
Parameters
- target
Cfn
Resource
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
addMetadata(key, value)
public addMetadata(key: string, value: any): void
Parameters
- key
string
- value
any
Add a value to the CloudFormation Resource Metadata.
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.)
addOverride(path, value)
public addOverride(path: string, value: any): void
Parameters
- path
string
— - The path of the property, you can use dot notation to override values in complex types. - value
any
— - The value.
Adds an override to the synthesized CloudFormation resource.
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,
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']);
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.1.ProjectionType', 'INCLUDE');
would add the overrides
"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.
addPropertyDeletionOverride(propertyPath)
public addPropertyDeletionOverride(propertyPath: string): void
Parameters
- propertyPath
string
— The path to the property.
Adds an override that deletes the value of a property from the resource definition.
addPropertyOverride(propertyPath, value)
public addPropertyOverride(propertyPath: string, value: any): void
Parameters
- propertyPath
string
— The path of the property. - value
any
— The value.
Adds an override to a resource property.
Syntactic sugar for addOverride("Properties.<...>", value)
.
applyRemovalPolicy(policy?, options?)
public applyRemovalPolicy(policy?: RemovalPolicy, options?: RemovalPolicyOptions): void
Parameters
- policy
Removal
Policy - options
Removal
Policy Options
Sets the deletion policy of the resource based on the removal policy specified.
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:
getAtt(attributeName, typeHint?)
public getAtt(attributeName: string, typeHint?: ResolutionTypeHint): Reference
Parameters
- attributeName
string
— The name of the attribute. - typeHint
Resolution
Type Hint
Returns
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.
getMetadata(key)
public getMetadata(key: string): any
Parameters
- key
string
Returns
any
Retrieve a value value from the CloudFormation Resource Metadata.
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.)
inspect(inspector)
public inspect(inspector: TreeInspector): void
Parameters
- inspector
Tree
— tree inspector to collect and process attributes.Inspector
Examines the CloudFormation resource and discloses attributes.
obtainDependencies()
public obtainDependencies(): Stack | CfnResource[]
Returns
Stack
|
Cfn
Resource []
Retrieves an array of resources this resource depends on.
This assembles dependencies on resources across stacks (including nested stacks) automatically.
obtainResourceDependencies()
public obtainResourceDependencies(): CfnResource[]
Returns
Get a shallow copy of dependencies between this resource and other resources in the same stack.
overrideLogicalId(newLogicalId)
public overrideLogicalId(newLogicalId: string): void
Parameters
- newLogicalId
string
— The new logical ID to use for this stack element.
Overrides the auto-generated logical ID with a specific ID.
removeDependency(target)
public removeDependency(target: CfnResource): void
Parameters
- target
Cfn
Resource
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, newTarget)
public replaceDependency(target: CfnResource, newTarget: CfnResource): void
Parameters
- target
Cfn
— The dependency to replace.Resource - newTarget
Cfn
— The new dependency to add.Resource
Replaces one dependency with another.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
protected renderProperties(props)
protected renderProperties(props: { [string]: any }): { [string]: any }
Parameters
- props
{ [string]: any }
Returns
{ [string]: any }