CfnInstance L1 construct
Specifies an EC2 instance.
If an Elastic IP address is attached to your instance, AWS CloudFormation reattaches the Elastic IP address after it updates the instance. For more information about updating stacks, see AWS CloudFormation Stacks Updates .
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
const cfnInstance = new ec2.CfnInstance(this, 'MyCfnInstance', /* all optional props */ {
additionalInfo: 'additionalInfo',
affinity: 'affinity',
availabilityZone: 'availabilityZone',
blockDeviceMappings: [{
deviceName: 'deviceName',
// the properties below are optional
ebs: {
deleteOnTermination: false,
encrypted: false,
iops: 123,
kmsKeyId: 'kmsKeyId',
snapshotId: 'snapshotId',
volumeSize: 123,
volumeType: 'volumeType',
},
noDevice: { },
virtualName: 'virtualName',
}],
cpuOptions: {
coreCount: 123,
threadsPerCore: 123,
},
creditSpecification: {
cpuCredits: 'cpuCredits',
},
disableApiTermination: false,
ebsOptimized: false,
elasticGpuSpecifications: [{
type: 'type',
}],
elasticInferenceAccelerators: [{
type: 'type',
// the properties below are optional
count: 123,
}],
enclaveOptions: {
enabled: false,
},
hibernationOptions: {
configured: false,
},
hostId: 'hostId',
hostResourceGroupArn: 'hostResourceGroupArn',
iamInstanceProfile: 'iamInstanceProfile',
imageId: 'imageId',
instanceInitiatedShutdownBehavior: 'instanceInitiatedShutdownBehavior',
instanceType: 'instanceType',
ipv6AddressCount: 123,
ipv6Addresses: [{
ipv6Address: 'ipv6Address',
}],
kernelId: 'kernelId',
keyName: 'keyName',
launchTemplate: {
version: 'version',
// the properties below are optional
launchTemplateId: 'launchTemplateId',
launchTemplateName: 'launchTemplateName',
},
licenseSpecifications: [{
licenseConfigurationArn: 'licenseConfigurationArn',
}],
metadataOptions: {
httpEndpoint: 'httpEndpoint',
httpProtocolIpv6: 'httpProtocolIpv6',
httpPutResponseHopLimit: 123,
httpTokens: 'httpTokens',
instanceMetadataTags: 'instanceMetadataTags',
},
monitoring: false,
networkInterfaces: [{
deviceIndex: 'deviceIndex',
// the properties below are optional
associateCarrierIpAddress: false,
associatePublicIpAddress: false,
deleteOnTermination: false,
description: 'description',
enaSrdSpecification: {
enaSrdEnabled: false,
enaSrdUdpSpecification: {
enaSrdUdpEnabled: false,
},
},
groupSet: ['groupSet'],
ipv6AddressCount: 123,
ipv6Addresses: [{
ipv6Address: 'ipv6Address',
}],
networkInterfaceId: 'networkInterfaceId',
privateIpAddress: 'privateIpAddress',
privateIpAddresses: [{
primary: false,
privateIpAddress: 'privateIpAddress',
}],
secondaryPrivateIpAddressCount: 123,
subnetId: 'subnetId',
}],
placementGroupName: 'placementGroupName',
privateDnsNameOptions: {
enableResourceNameDnsAaaaRecord: false,
enableResourceNameDnsARecord: false,
hostnameType: 'hostnameType',
},
privateIpAddress: 'privateIpAddress',
propagateTagsToVolumeOnCreation: false,
ramdiskId: 'ramdiskId',
securityGroupIds: ['securityGroupIds'],
securityGroups: ['securityGroups'],
sourceDestCheck: false,
ssmAssociations: [{
documentName: 'documentName',
// the properties below are optional
associationParameters: [{
key: 'key',
value: ['value'],
}],
}],
subnetId: 'subnetId',
tags: [{
key: 'key',
value: 'value',
}],
tenancy: 'tenancy',
userData: 'userData',
volumes: [{
device: 'device',
volumeId: 'volumeId',
}],
});
from aws_cdk import CfnTag
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_ec2 as ec2
cfn_instance = ec2.CfnInstance(self, "MyCfnInstance",
additional_info="additionalInfo",
affinity="affinity",
availability_zone="availabilityZone",
block_device_mappings=[ec2.CfnInstance.BlockDeviceMappingProperty(
device_name="deviceName",
# the properties below are optional
ebs=ec2.CfnInstance.EbsProperty(
delete_on_termination=False,
encrypted=False,
iops=123,
kms_key_id="kmsKeyId",
snapshot_id="snapshotId",
volume_size=123,
volume_type="volumeType"
),
no_device=ec2.CfnInstance.NoDeviceProperty(),
virtual_name="virtualName"
)],
cpu_options=ec2.CfnInstance.CpuOptionsProperty(
core_count=123,
threads_per_core=123
),
credit_specification=ec2.CfnInstance.CreditSpecificationProperty(
cpu_credits="cpuCredits"
),
disable_api_termination=False,
ebs_optimized=False,
elastic_gpu_specifications=[ec2.CfnInstance.ElasticGpuSpecificationProperty(
type="type"
)],
elastic_inference_accelerators=[ec2.CfnInstance.ElasticInferenceAcceleratorProperty(
type="type",
# the properties below are optional
count=123
)],
enclave_options=ec2.CfnInstance.EnclaveOptionsProperty(
enabled=False
),
hibernation_options=ec2.CfnInstance.HibernationOptionsProperty(
configured=False
),
host_id="hostId",
host_resource_group_arn="hostResourceGroupArn",
iam_instance_profile="iamInstanceProfile",
image_id="imageId",
instance_initiated_shutdown_behavior="instanceInitiatedShutdownBehavior",
instance_type="instanceType",
ipv6_address_count=123,
ipv6_addresses=[ec2.CfnInstance.InstanceIpv6AddressProperty(
ipv6_address="ipv6Address"
)],
kernel_id="kernelId",
key_name="keyName",
launch_template=ec2.CfnInstance.LaunchTemplateSpecificationProperty(
version="version",
# the properties below are optional
launch_template_id="launchTemplateId",
launch_template_name="launchTemplateName"
),
license_specifications=[ec2.CfnInstance.LicenseSpecificationProperty(
license_configuration_arn="licenseConfigurationArn"
)],
metadata_options=ec2.CfnInstance.MetadataOptionsProperty(
http_endpoint="httpEndpoint",
http_protocol_ipv6="httpProtocolIpv6",
http_put_response_hop_limit=123,
http_tokens="httpTokens",
instance_metadata_tags="instanceMetadataTags"
),
monitoring=False,
network_interfaces=[ec2.CfnInstance.NetworkInterfaceProperty(
device_index="deviceIndex",
# the properties below are optional
associate_carrier_ip_address=False,
associate_public_ip_address=False,
delete_on_termination=False,
description="description",
ena_srd_specification=ec2.CfnInstance.EnaSrdSpecificationProperty(
ena_srd_enabled=False,
ena_srd_udp_specification=ec2.CfnInstance.EnaSrdUdpSpecificationProperty(
ena_srd_udp_enabled=False
)
),
group_set=["groupSet"],
ipv6_address_count=123,
ipv6_addresses=[ec2.CfnInstance.InstanceIpv6AddressProperty(
ipv6_address="ipv6Address"
)],
network_interface_id="networkInterfaceId",
private_ip_address="privateIpAddress",
private_ip_addresses=[ec2.CfnInstance.PrivateIpAddressSpecificationProperty(
primary=False,
private_ip_address="privateIpAddress"
)],
secondary_private_ip_address_count=123,
subnet_id="subnetId"
)],
placement_group_name="placementGroupName",
private_dns_name_options=ec2.CfnInstance.PrivateDnsNameOptionsProperty(
enable_resource_name_dns_aaaa_record=False,
enable_resource_name_dns_a_record=False,
hostname_type="hostnameType"
),
private_ip_address="privateIpAddress",
propagate_tags_to_volume_on_creation=False,
ramdisk_id="ramdiskId",
security_group_ids=["securityGroupIds"],
security_groups=["securityGroups"],
source_dest_check=False,
ssm_associations=[ec2.CfnInstance.SsmAssociationProperty(
document_name="documentName",
# the properties below are optional
association_parameters=[ec2.CfnInstance.AssociationParameterProperty(
key="key",
value=["value"]
)]
)],
subnet_id="subnetId",
tags=[CfnTag(
key="key",
value="value"
)],
tenancy="tenancy",
user_data="userData",
volumes=[ec2.CfnInstance.VolumeProperty(
device="device",
volume_id="volumeId"
)]
)
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.ec2.*;
CfnInstance cfnInstance = CfnInstance.Builder.create(this, "MyCfnInstance")
.additionalInfo("additionalInfo")
.affinity("affinity")
.availabilityZone("availabilityZone")
.blockDeviceMappings(List.of(BlockDeviceMappingProperty.builder()
.deviceName("deviceName")
// the properties below are optional
.ebs(EbsProperty.builder()
.deleteOnTermination(false)
.encrypted(false)
.iops(123)
.kmsKeyId("kmsKeyId")
.snapshotId("snapshotId")
.volumeSize(123)
.volumeType("volumeType")
.build())
.noDevice(NoDeviceProperty.builder().build())
.virtualName("virtualName")
.build()))
.cpuOptions(CpuOptionsProperty.builder()
.coreCount(123)
.threadsPerCore(123)
.build())
.creditSpecification(CreditSpecificationProperty.builder()
.cpuCredits("cpuCredits")
.build())
.disableApiTermination(false)
.ebsOptimized(false)
.elasticGpuSpecifications(List.of(ElasticGpuSpecificationProperty.builder()
.type("type")
.build()))
.elasticInferenceAccelerators(List.of(ElasticInferenceAcceleratorProperty.builder()
.type("type")
// the properties below are optional
.count(123)
.build()))
.enclaveOptions(EnclaveOptionsProperty.builder()
.enabled(false)
.build())
.hibernationOptions(HibernationOptionsProperty.builder()
.configured(false)
.build())
.hostId("hostId")
.hostResourceGroupArn("hostResourceGroupArn")
.iamInstanceProfile("iamInstanceProfile")
.imageId("imageId")
.instanceInitiatedShutdownBehavior("instanceInitiatedShutdownBehavior")
.instanceType("instanceType")
.ipv6AddressCount(123)
.ipv6Addresses(List.of(InstanceIpv6AddressProperty.builder()
.ipv6Address("ipv6Address")
.build()))
.kernelId("kernelId")
.keyName("keyName")
.launchTemplate(LaunchTemplateSpecificationProperty.builder()
.version("version")
// the properties below are optional
.launchTemplateId("launchTemplateId")
.launchTemplateName("launchTemplateName")
.build())
.licenseSpecifications(List.of(LicenseSpecificationProperty.builder()
.licenseConfigurationArn("licenseConfigurationArn")
.build()))
.metadataOptions(MetadataOptionsProperty.builder()
.httpEndpoint("httpEndpoint")
.httpProtocolIpv6("httpProtocolIpv6")
.httpPutResponseHopLimit(123)
.httpTokens("httpTokens")
.instanceMetadataTags("instanceMetadataTags")
.build())
.monitoring(false)
.networkInterfaces(List.of(NetworkInterfaceProperty.builder()
.deviceIndex("deviceIndex")
// the properties below are optional
.associateCarrierIpAddress(false)
.associatePublicIpAddress(false)
.deleteOnTermination(false)
.description("description")
.enaSrdSpecification(EnaSrdSpecificationProperty.builder()
.enaSrdEnabled(false)
.enaSrdUdpSpecification(EnaSrdUdpSpecificationProperty.builder()
.enaSrdUdpEnabled(false)
.build())
.build())
.groupSet(List.of("groupSet"))
.ipv6AddressCount(123)
.ipv6Addresses(List.of(InstanceIpv6AddressProperty.builder()
.ipv6Address("ipv6Address")
.build()))
.networkInterfaceId("networkInterfaceId")
.privateIpAddress("privateIpAddress")
.privateIpAddresses(List.of(PrivateIpAddressSpecificationProperty.builder()
.primary(false)
.privateIpAddress("privateIpAddress")
.build()))
.secondaryPrivateIpAddressCount(123)
.subnetId("subnetId")
.build()))
.placementGroupName("placementGroupName")
.privateDnsNameOptions(PrivateDnsNameOptionsProperty.builder()
.enableResourceNameDnsAaaaRecord(false)
.enableResourceNameDnsARecord(false)
.hostnameType("hostnameType")
.build())
.privateIpAddress("privateIpAddress")
.propagateTagsToVolumeOnCreation(false)
.ramdiskId("ramdiskId")
.securityGroupIds(List.of("securityGroupIds"))
.securityGroups(List.of("securityGroups"))
.sourceDestCheck(false)
.ssmAssociations(List.of(SsmAssociationProperty.builder()
.documentName("documentName")
// the properties below are optional
.associationParameters(List.of(AssociationParameterProperty.builder()
.key("key")
.value(List.of("value"))
.build()))
.build()))
.subnetId("subnetId")
.tags(List.of(CfnTag.builder()
.key("key")
.value("value")
.build()))
.tenancy("tenancy")
.userData("userData")
.volumes(List.of(VolumeProperty.builder()
.device("device")
.volumeId("volumeId")
.build()))
.build();
// 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.EC2;
var cfnInstance = new CfnInstance(this, "MyCfnInstance", new CfnInstanceProps {
AdditionalInfo = "additionalInfo",
Affinity = "affinity",
AvailabilityZone = "availabilityZone",
BlockDeviceMappings = new [] { new BlockDeviceMappingProperty {
DeviceName = "deviceName",
// the properties below are optional
Ebs = new EbsProperty {
DeleteOnTermination = false,
Encrypted = false,
Iops = 123,
KmsKeyId = "kmsKeyId",
SnapshotId = "snapshotId",
VolumeSize = 123,
VolumeType = "volumeType"
},
NoDevice = new NoDeviceProperty { },
VirtualName = "virtualName"
} },
CpuOptions = new CpuOptionsProperty {
CoreCount = 123,
ThreadsPerCore = 123
},
CreditSpecification = new CreditSpecificationProperty {
CpuCredits = "cpuCredits"
},
DisableApiTermination = false,
EbsOptimized = false,
ElasticGpuSpecifications = new [] { new ElasticGpuSpecificationProperty {
Type = "type"
} },
ElasticInferenceAccelerators = new [] { new ElasticInferenceAcceleratorProperty {
Type = "type",
// the properties below are optional
Count = 123
} },
EnclaveOptions = new EnclaveOptionsProperty {
Enabled = false
},
HibernationOptions = new HibernationOptionsProperty {
Configured = false
},
HostId = "hostId",
HostResourceGroupArn = "hostResourceGroupArn",
IamInstanceProfile = "iamInstanceProfile",
ImageId = "imageId",
InstanceInitiatedShutdownBehavior = "instanceInitiatedShutdownBehavior",
InstanceType = "instanceType",
Ipv6AddressCount = 123,
Ipv6Addresses = new [] { new InstanceIpv6AddressProperty {
Ipv6Address = "ipv6Address"
} },
KernelId = "kernelId",
KeyName = "keyName",
LaunchTemplate = new LaunchTemplateSpecificationProperty {
Version = "version",
// the properties below are optional
LaunchTemplateId = "launchTemplateId",
LaunchTemplateName = "launchTemplateName"
},
LicenseSpecifications = new [] { new LicenseSpecificationProperty {
LicenseConfigurationArn = "licenseConfigurationArn"
} },
MetadataOptions = new MetadataOptionsProperty {
HttpEndpoint = "httpEndpoint",
HttpProtocolIpv6 = "httpProtocolIpv6",
HttpPutResponseHopLimit = 123,
HttpTokens = "httpTokens",
InstanceMetadataTags = "instanceMetadataTags"
},
Monitoring = false,
NetworkInterfaces = new [] { new NetworkInterfaceProperty {
DeviceIndex = "deviceIndex",
// the properties below are optional
AssociateCarrierIpAddress = false,
AssociatePublicIpAddress = false,
DeleteOnTermination = false,
Description = "description",
EnaSrdSpecification = new EnaSrdSpecificationProperty {
EnaSrdEnabled = false,
EnaSrdUdpSpecification = new EnaSrdUdpSpecificationProperty {
EnaSrdUdpEnabled = false
}
},
GroupSet = new [] { "groupSet" },
Ipv6AddressCount = 123,
Ipv6Addresses = new [] { new InstanceIpv6AddressProperty {
Ipv6Address = "ipv6Address"
} },
NetworkInterfaceId = "networkInterfaceId",
PrivateIpAddress = "privateIpAddress",
PrivateIpAddresses = new [] { new PrivateIpAddressSpecificationProperty {
Primary = false,
PrivateIpAddress = "privateIpAddress"
} },
SecondaryPrivateIpAddressCount = 123,
SubnetId = "subnetId"
} },
PlacementGroupName = "placementGroupName",
PrivateDnsNameOptions = new PrivateDnsNameOptionsProperty {
EnableResourceNameDnsAaaaRecord = false,
EnableResourceNameDnsARecord = false,
HostnameType = "hostnameType"
},
PrivateIpAddress = "privateIpAddress",
PropagateTagsToVolumeOnCreation = false,
RamdiskId = "ramdiskId",
SecurityGroupIds = new [] { "securityGroupIds" },
SecurityGroups = new [] { "securityGroups" },
SourceDestCheck = false,
SsmAssociations = new [] { new SsmAssociationProperty {
DocumentName = "documentName",
// the properties below are optional
AssociationParameters = new [] { new AssociationParameterProperty {
Key = "key",
Value = new [] { "value" }
} }
} },
SubnetId = "subnetId",
Tags = new [] { new CfnTag {
Key = "key",
Value = "value"
} },
Tenancy = "tenancy",
UserData = "userData",
Volumes = new [] { new VolumeProperty {
Device = "device",
VolumeId = "volumeId"
} }
});
// 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"
cfnInstance := awscdk.Aws_ec2.NewCfnInstance(this, jsii.String("MyCfnInstance"), &CfnInstanceProps{
AdditionalInfo: jsii.String("additionalInfo"),
Affinity: jsii.String("affinity"),
AvailabilityZone: jsii.String("availabilityZone"),
BlockDeviceMappings: []interface{}{
&BlockDeviceMappingProperty{
DeviceName: jsii.String("deviceName"),
// the properties below are optional
Ebs: &EbsProperty{
DeleteOnTermination: jsii.Boolean(false),
Encrypted: jsii.Boolean(false),
Iops: jsii.Number(123),
KmsKeyId: jsii.String("kmsKeyId"),
SnapshotId: jsii.String("snapshotId"),
VolumeSize: jsii.Number(123),
VolumeType: jsii.String("volumeType"),
},
NoDevice: &NoDeviceProperty{
},
VirtualName: jsii.String("virtualName"),
},
},
CpuOptions: &CpuOptionsProperty{
CoreCount: jsii.Number(123),
ThreadsPerCore: jsii.Number(123),
},
CreditSpecification: &CreditSpecificationProperty{
CpuCredits: jsii.String("cpuCredits"),
},
DisableApiTermination: jsii.Boolean(false),
EbsOptimized: jsii.Boolean(false),
ElasticGpuSpecifications: []interface{}{
&ElasticGpuSpecificationProperty{
Type: jsii.String("type"),
},
},
ElasticInferenceAccelerators: []interface{}{
&ElasticInferenceAcceleratorProperty{
Type: jsii.String("type"),
// the properties below are optional
Count: jsii.Number(123),
},
},
EnclaveOptions: &EnclaveOptionsProperty{
Enabled: jsii.Boolean(false),
},
HibernationOptions: &HibernationOptionsProperty{
Configured: jsii.Boolean(false),
},
HostId: jsii.String("hostId"),
HostResourceGroupArn: jsii.String("hostResourceGroupArn"),
IamInstanceProfile: jsii.String("iamInstanceProfile"),
ImageId: jsii.String("imageId"),
InstanceInitiatedShutdownBehavior: jsii.String("instanceInitiatedShutdownBehavior"),
InstanceType: jsii.String("instanceType"),
Ipv6AddressCount: jsii.Number(123),
Ipv6Addresses: []interface{}{
&InstanceIpv6AddressProperty{
Ipv6Address: jsii.String("ipv6Address"),
},
},
KernelId: jsii.String("kernelId"),
KeyName: jsii.String("keyName"),
LaunchTemplate: &LaunchTemplateSpecificationProperty{
Version: jsii.String("version"),
// the properties below are optional
LaunchTemplateId: jsii.String("launchTemplateId"),
LaunchTemplateName: jsii.String("launchTemplateName"),
},
LicenseSpecifications: []interface{}{
&LicenseSpecificationProperty{
LicenseConfigurationArn: jsii.String("licenseConfigurationArn"),
},
},
MetadataOptions: &MetadataOptionsProperty{
HttpEndpoint: jsii.String("httpEndpoint"),
HttpProtocolIpv6: jsii.String("httpProtocolIpv6"),
HttpPutResponseHopLimit: jsii.Number(123),
HttpTokens: jsii.String("httpTokens"),
InstanceMetadataTags: jsii.String("instanceMetadataTags"),
},
Monitoring: jsii.Boolean(false),
NetworkInterfaces: []interface{}{
&NetworkInterfaceProperty{
DeviceIndex: jsii.String("deviceIndex"),
// the properties below are optional
AssociateCarrierIpAddress: jsii.Boolean(false),
AssociatePublicIpAddress: jsii.Boolean(false),
DeleteOnTermination: jsii.Boolean(false),
Description: jsii.String("description"),
EnaSrdSpecification: &EnaSrdSpecificationProperty{
EnaSrdEnabled: jsii.Boolean(false),
EnaSrdUdpSpecification: &EnaSrdUdpSpecificationProperty{
EnaSrdUdpEnabled: jsii.Boolean(false),
},
},
GroupSet: []*string{
jsii.String("groupSet"),
},
Ipv6AddressCount: jsii.Number(123),
Ipv6Addresses: []interface{}{
&InstanceIpv6AddressProperty{
Ipv6Address: jsii.String("ipv6Address"),
},
},
NetworkInterfaceId: jsii.String("networkInterfaceId"),
PrivateIpAddress: jsii.String("privateIpAddress"),
PrivateIpAddresses: []interface{}{
&PrivateIpAddressSpecificationProperty{
Primary: jsii.Boolean(false),
PrivateIpAddress: jsii.String("privateIpAddress"),
},
},
SecondaryPrivateIpAddressCount: jsii.Number(123),
SubnetId: jsii.String("subnetId"),
},
},
PlacementGroupName: jsii.String("placementGroupName"),
PrivateDnsNameOptions: &PrivateDnsNameOptionsProperty{
EnableResourceNameDnsAaaaRecord: jsii.Boolean(false),
EnableResourceNameDnsARecord: jsii.Boolean(false),
HostnameType: jsii.String("hostnameType"),
},
PrivateIpAddress: jsii.String("privateIpAddress"),
PropagateTagsToVolumeOnCreation: jsii.Boolean(false),
RamdiskId: jsii.String("ramdiskId"),
SecurityGroupIds: []interface{}{
jsii.String("securityGroupIds"),
},
SecurityGroups: []*string{
jsii.String("securityGroups"),
},
SourceDestCheck: jsii.Boolean(false),
SsmAssociations: []interface{}{
&SsmAssociationProperty{
DocumentName: jsii.String("documentName"),
// the properties below are optional
AssociationParameters: []interface{}{
&AssociationParameterProperty{
Key: jsii.String("key"),
Value: []*string{
jsii.String("value"),
},
},
},
},
},
SubnetId: jsii.String("subnetId"),
Tags: []CfnTag{
&CfnTag{
Key: jsii.String("key"),
Value: jsii.String("value"),
},
},
Tenancy: jsii.String("tenancy"),
UserData: jsii.String("userData"),
Volumes: []interface{}{
&VolumeProperty{
Device: jsii.String("device"),
VolumeId: jsii.String("volumeId"),
},
},
})
Initializer
new CfnInstance(scope: Construct, id: string, props?: CfnInstanceProps)
CfnInstance(scope: Construct, id: str, props: typing.Optional[CfnInstanceProps] = None)
new CfnInstance(Construct scope, String id, CfnInstanceProps props)
new CfnInstance(Construct scope, string id, CfnInstanceProps? props = null)
NewCfnInstance(Scope Construct, Id *string, Props CfnInstanceProps)
Construct Props
additionalInfooptionalstringadditional_infooptionalstradditionalInfooptionalStringAdditionalInfooptionalstringAdditionalInfooptional*string#If you use it, the stack fails with this error: Bad property set: [Testing this property] (Service: AmazonEC2; Status Code: 400; Error Code: InvalidParameterCombination; Request ID: 0XXXXXX-49c7-4b40-8bcc-76885dcXXXXX) .
affinityoptionalstringaffinityoptionalstraffinityoptionalStringAffinityoptionalstringAffinityoptional*string#notes
If you want the instance to always restart on the same host on which it was launched, specify host . If you want the instance to restart on any available host, but try to launch onto the last host it ran on (on a best-effort basis), specify default .
availabilityZoneoptionalstringavailability_zoneoptionalstravailabilityZoneoptionalStringAvailabilityZoneoptionalstringAvailabilityZoneoptional*string#notes
If not specified, an Availability Zone will be automatically chosen for you based on the load balancing criteria for the Region.
This parameter is not supported by DescribeImageAttribute .
blockDeviceMappingsoptionalIResolvable | IResolvable | CfnInstance.BlockDeviceMappingProperty[]block_device_mappingsoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, BlockDeviceMappingProperty]]]blockDeviceMappingsoptionalIResolvableBlockDeviceMappingsoptionalIResolvableBlockDeviceMappingsoptionalinterface{}#notes
By default, the block devices specified in the block device mapping for the AMI are used. You can override the AMI block device mapping using the instance block device mapping. For the root volume, you can override only the volume size, volume type, volume encryption settings, and the DeleteOnTermination setting.
After the instance is running, you can modify only the
DeleteOnTerminationparameter for the attached volumes without interrupting the instance. Modifying any other parameter results in instance replacement .
cpuOptionsoptionalIResolvable | CfnInstance.CpuOptionsPropertycpu_optionsoptionaltyping.Union[IResolvable, CpuOptionsProperty]cpuOptionsoptionalIResolvableCpuOptionsoptionalIResolvableCpuOptionsoptionalinterface{}#For more information, see Optimize CPU options in the Amazon Elastic Compute Cloud User Guide .
creditSpecificationoptionalIResolvable | CfnInstance.CreditSpecificationPropertycredit_specificationoptionaltyping.Union[IResolvable, CreditSpecificationProperty]creditSpecificationoptionalIResolvableCreditSpecificationoptionalIResolvableCreditSpecificationoptionalinterface{}#notes
Valid values are standard and unlimited . To change this attribute after launch, use ModifyInstanceCreditSpecification . For more information, see Burstable performance instances in the Amazon EC2 User Guide .
Default: standard (T2 instances) or unlimited (T3/T3a/T4g instances)
For T3 instances with host tenancy, only standard is supported.
disableApiTerminationoptionalboolean | IResolvabledisable_api_terminationoptionaltyping.Union[bool, IResolvable]disableApiTerminationoptionalBooleanDisableApiTerminationoptionalboolDisableApiTerminationoptionalinterface{}#notes
The default is false , which means that you can terminate the instance using the Amazon EC2 console, command line tools, or API. You can enable termination protection when you launch an instance, while the instance is running, or while the instance is stopped.
ebsOptimizedoptionalboolean | IResolvableebs_optimizedoptionaltyping.Union[bool, IResolvable]ebsOptimizedoptionalBooleanEbsOptimizedoptionalboolEbsOptimizedoptionalinterface{}#notes
This optimization provides dedicated throughput to Amazon EBS and an optimized configuration stack to provide optimal Amazon EBS I/O performance. This optimization isn't available with all instance types. Additional usage charges apply when using an EBS-optimized instance.
Default: false
elasticGpuSpecificationsoptionalIResolvable | IResolvable | CfnInstance.ElasticGpuSpecificationProperty[]elastic_gpu_specificationsoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, ElasticGpuSpecificationProperty]]]elasticGpuSpecificationsoptionalIResolvableElasticGpuSpecificationsoptionalIResolvableElasticGpuSpecificationsoptionalinterface{}#Amazon Elastic Graphics reached end of life on January 8, 2024.
elasticInferenceAcceleratorsoptionalIResolvable | IResolvable | CfnInstance.ElasticInferenceAcceleratorProperty[]elastic_inference_acceleratorsoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, ElasticInferenceAcceleratorProperty]]]elasticInferenceAcceleratorsoptionalIResolvableElasticInferenceAcceleratorsoptionalIResolvableElasticInferenceAcceleratorsoptionalinterface{}#Amazon Elastic Inference is no longer available.
enclaveOptionsoptionalIResolvable | CfnInstance.EnclaveOptionsPropertyenclave_optionsoptionaltyping.Union[IResolvable, EnclaveOptionsProperty]enclaveOptionsoptionalIResolvableEnclaveOptionsoptionalIResolvableEnclaveOptionsoptionalinterface{}#hibernationOptionsoptionalIResolvable | CfnInstance.HibernationOptionsPropertyhibernation_optionsoptionaltyping.Union[IResolvable, HibernationOptionsProperty]hibernationOptionsoptionalIResolvableHibernationOptionsoptionalIResolvableHibernationOptionsoptionalinterface{}#notes
This parameter is valid only if the instance meets the hibernation prerequisites . For more information, see Hibernate your Amazon EC2 instance in the Amazon EC2 User Guide .
You can't enable hibernation and AWS Nitro Enclaves on the same instance.
hostIdoptionalstring | IHostRefhost_idoptionaltyping.Union[str, IHostRef]hostIdoptionalStringHostIdoptionalstringHostIdoptionalinterface{}#notes
If you don't specify an ID, Amazon EC2 launches the instance onto any available, compatible dedicated host in your account. This type of launch is called an untargeted launch. Note that for untargeted launches, you must have a compatible, dedicated host available to successfully launch instances.
hostResourceGroupArnoptionalstringhost_resource_group_arnoptionalstrhostResourceGroupArnoptionalStringHostResourceGroupArnoptionalstringHostResourceGroupArnoptional*string#If you specify a host resource group ARN, omit the Tenancy parameter or set it to host .
iamInstanceProfileoptionalstring | IInstanceProfileRefiam_instance_profileoptionaltyping.Union[str, IInstanceProfileRef]iamInstanceProfileoptionalStringIamInstanceProfileoptionalstringIamInstanceProfileoptionalinterface{}#To create a new IAM instance profile, use the AWS::IAM::InstanceProfile resource.
imageIdoptionalstringimage_idoptionalstrimageIdoptionalStringImageIdoptionalstringImageIdoptional*string#An AMI ID is required to launch an instance and must be specified here or in a launch template.
instanceInitiatedShutdownBehavioroptionalstringinstance_initiated_shutdown_behavioroptionalstrinstanceInitiatedShutdownBehavioroptionalStringInstanceInitiatedShutdownBehavioroptionalstringInstanceInitiatedShutdownBehavioroptional*string#Default: stop
instanceTypeoptionalstringinstance_typeoptionalstrinstanceTypeoptionalStringInstanceTypeoptionalstringInstanceTypeoptional*string#notes
When you change your EBS-backed instance type, instance restart or replacement behavior depends on the instance type compatibility between the old and new types. An instance with an instance store volume as the root volume is always replaced. For more information, see Change the instance type in the Amazon EC2 User Guide .
ipv6AddressCountoptionalnumberipv6_address_countoptionalint | floatipv6AddressCountoptionalNumberIpv6AddressCountoptionaldoubleIpv6AddressCountoptional*float64#notes
Amazon EC2 chooses the IPv6 addresses from the range of your subnet. You cannot specify this option and the option to assign specific IPv6 addresses in the same request. You can specify this option if you've specified a minimum number of instances to launch.
You cannot specify this option and the network interfaces option in the same request.
ipv6AddressesoptionalIResolvable | IResolvable | CfnInstance.InstanceIpv6AddressProperty[]ipv6_addressesoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, InstanceIpv6AddressProperty]]]ipv6AddressesoptionalIResolvableIpv6AddressesoptionalIResolvableIpv6Addressesoptionalinterface{}#notes
You cannot specify this option and the option to assign a number of IPv6 addresses in the same request. You cannot specify this option if you've specified a minimum number of instances to launch.
You cannot specify this option and the network interfaces option in the same request.
kernelIdoptionalstringkernel_idoptionalstrkernelIdoptionalStringKernelIdoptionalstringKernelIdoptional*string#We recommend that you use PV-GRUB instead of kernels and RAM disks. For more information, see PV-GRUB in the Amazon EC2 User Guide .
keyNameoptionalstringkey_nameoptionalstrkeyNameoptionalStringKeyNameoptionalstringKeyNameoptional*string#If you do not specify a key pair, you can't connect to the instance unless you choose an AMI that is configured to allow users another way to log in.
launchTemplateoptionalIResolvable | CfnInstance.LaunchTemplateSpecificationPropertylaunch_templateoptionaltyping.Union[IResolvable, LaunchTemplateSpecificationProperty]launchTemplateoptionalIResolvableLaunchTemplateoptionalIResolvableLaunchTemplateoptionalinterface{}#Any additional parameters that you specify for the new instance overwrite the corresponding parameters included in the launch template.
licenseSpecificationsoptionalIResolvable | IResolvable | CfnInstance.LicenseSpecificationProperty[]license_specificationsoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, LicenseSpecificationProperty]]]licenseSpecificationsoptionalIResolvableLicenseSpecificationsoptionalIResolvableLicenseSpecificationsoptionalinterface{}#metadataOptionsoptionalIResolvable | CfnInstance.MetadataOptionsPropertymetadata_optionsoptionaltyping.Union[IResolvable, MetadataOptionsProperty]metadataOptionsoptionalIResolvableMetadataOptionsoptionalIResolvableMetadataOptionsoptionalinterface{}#monitoringoptionalboolean | IResolvablemonitoringoptionaltyping.Union[bool, IResolvable]monitoringoptionalBooleanMonitoringoptionalboolMonitoringoptionalinterface{}#notes
Specify true to enable detailed monitoring. Otherwise, basic monitoring is enabled. For more information about detailed monitoring, see Enable or turn off detailed monitoring for your instances in the Amazon EC2 User Guide .
networkInterfacesoptionalIResolvable | IResolvable | CfnInstance.NetworkInterfaceProperty[]network_interfacesoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, NetworkInterfaceProperty]]]networkInterfacesoptionalIResolvableNetworkInterfacesoptionalIResolvableNetworkInterfacesoptionalinterface{}#notes
If you use this property to point to a network interface, you must terminate the original interface before attaching a new one to allow the update of the instance to succeed.
If this resource has a public IP address and is also in a VPC that is defined in the same template, you must use the DependsOn Attribute to declare a dependency on the VPC-gateway attachment.
placementGroupNameoptionalstring | IPlacementGroupRefplacement_group_nameoptionaltyping.Union[str, IPlacementGroupRef]placementGroupNameoptionalStringPlacementGroupNameoptionalstringPlacementGroupNameoptionalinterface{}#privateDnsNameOptionsoptionalIResolvable | CfnInstance.PrivateDnsNameOptionsPropertyprivate_dns_name_optionsoptionaltyping.Union[IResolvable, PrivateDnsNameOptionsProperty]privateDnsNameOptionsoptionalIResolvablePrivateDnsNameOptionsoptionalIResolvablePrivateDnsNameOptionsoptionalinterface{}#privateIpAddressoptionalstringprivate_ip_addressoptionalstrprivateIpAddressoptionalStringPrivateIpAddressoptionalstringPrivateIpAddressoptional*string#notes
Only one private IP address can be designated as primary. You can't specify this option if you've specified the option to designate a private IP address as the primary IP address in a network interface specification. You cannot specify this option if you're launching more than one instance in the request.
You cannot specify this option and the network interfaces option in the same request.
If you make an update to an instance that requires replacement, you must assign a new private IP address. During a replacement, AWS CloudFormation creates a new instance but doesn't delete the old instance until the stack has successfully updated. If the stack update fails, AWS CloudFormation uses the old instance to roll back the stack to the previous working state. The old and new instances cannot have the same private IP address.
propagateTagsToVolumeOnCreationoptionalboolean | IResolvablepropagate_tags_to_volume_on_creationoptionaltyping.Union[bool, IResolvable]propagateTagsToVolumeOnCreationoptionalBooleanPropagateTagsToVolumeOnCreationoptionalboolPropagateTagsToVolumeOnCreationoptionalinterface{}#Note that using this feature does not assign the tags to volumes that are created separately and then attached using AWS::EC2::VolumeAttachment .
ramdiskIdoptionalstringramdisk_idoptionalstrramdiskIdoptionalStringRamdiskIdoptionalstringRamdiskIdoptional*string#notes
Some kernels require additional drivers at launch. Check the kernel requirements for information about whether you need to specify a RAM disk. To find kernel requirements, go to the AWS Resource Center and search for the kernel ID.
We recommend that you use PV-GRUB instead of kernels and RAM disks. For more information, see PV-GRUB in the Amazon EC2 User Guide .
securityGroupIdsoptionalstring | ISecurityGroupRef[]security_group_idsoptionaltyping.List[typing.Union[str, ISecurityGroupRef]]securityGroupIdsoptionalList<String>SecurityGroupIdsoptionalstring[]SecurityGroupIdsoptional*[]interface{}#You can specify the IDs of existing security groups and references to resources created by the stack template.
If you specify a network interface, you must specify any security groups as part of the network interface.
securityGroupsoptionalstring[]security_groupsoptionaltyping.List[str]securityGroupsoptionalList<String>SecurityGroupsoptionalstring[]SecurityGroupsoptional*[]*string#notes
You cannot specify this option and the network interfaces option in the same request. The list can contain both the name of existing Amazon EC2 security groups or references to AWS::EC2::SecurityGroup resources created in the template.
Default: Amazon EC2 uses the default security group.
sourceDestCheckoptionalboolean | IResolvablesource_dest_checkoptionaltyping.Union[bool, IResolvable]sourceDestCheckoptionalBooleanSourceDestCheckoptionalboolSourceDestCheckoptionalinterface{}#notes
If the value is true , source/destination checks are enabled; otherwise, they are disabled. The default value is true . You must disable source/destination checks if the instance runs services such as network address translation, routing, or firewalls.
ssmAssociationsoptionalIResolvable | IResolvable | CfnInstance.SsmAssociationProperty[]ssm_associationsoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, SsmAssociationProperty]]]ssmAssociationsoptionalIResolvableSsmAssociationsoptionalIResolvableSsmAssociationsoptionalinterface{}#You can associate only one document with an instance.
subnetIdoptionalstring | ISubnetRefsubnet_idoptionaltyping.Union[str, ISubnetRef]subnetIdoptionalStringSubnetIdoptionalstringSubnetIdoptionalinterface{}#If you specify a network interface, you must specify any subnets as part of the network interface instead of using this parameter.
tagsoptionalCfnTag[]tagsoptionaltyping.List[CfnTag]tagsoptionalList<CfnTag>TagsoptionalCfnTag[]Tagsoptional*[]CfnTag#notes
These tags are not applied to the EBS volumes, such as the root volume, unless PropagateTagsToVolumeOnCreation is true .
tenancyoptionalstringtenancyoptionalstrtenancyoptionalStringTenancyoptionalstringTenancyoptional*string#An instance with a tenancy of dedicated runs on single-tenant hardware.
userDataoptionalstringuser_dataoptionalstruserDataoptionalStringUserDataoptionalstringUserDataoptional*string#notes
Any scripts in user data are run when you launch the instance. User data is limited to 16 KB. You must provide base64-encoded text. For more information, see Fn::Base64 .
If the root volume is an EBS volume and you update user data, CloudFormation restarts the instance. If the root volume is an instance store volume and you update user data, the instance is replaced.
volumesoptionalIResolvable | IResolvable | CfnInstance.VolumeProperty[]volumesoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, VolumeProperty]]]volumesoptionalIResolvableVolumesoptionalIResolvableVolumesoptionalinterface{}#Properties
additionalInfomay be undefinedstringadditional_infomay be undefinedstradditionalInfomay be undefinedStringAdditionalInfomay be undefinedstringAdditionalInfomay be undefined*string#affinitymay be undefinedstringaffinitymay be undefinedstraffinitymay be undefinedStringAffinitymay be undefinedstringAffinitymay be undefined*string#attrAvailabilityZonestringattr_availability_zonestrattrAvailabilityZoneStringAttrAvailabilityZonestringAttrAvailabilityZone*string#attrInstanceIdstringattr_instance_idstrattrInstanceIdStringAttrInstanceIdstringAttrInstanceId*string#attrPrivateDnsNamestringattr_private_dns_namestrattrPrivateDnsNameStringAttrPrivateDnsNamestringAttrPrivateDnsName*string#For example: ip-10-24-34-0.ec2.internal .
For example: 10.24.34.0 .
attrPublicDnsNamestringattr_public_dns_namestrattrPublicDnsNameStringAttrPublicDnsNamestringAttrPublicDnsName*string#For example: ec2-107-20-50-45.compute-1.amazonaws.com .
For example: 192.0.2.0 .
attrStateIResolvableattr_stateIResolvableattrStateIResolvableAttrStateIResolvableAttrStateIResolvable#availabilityZonemay be undefinedstringavailability_zonemay be undefinedstravailabilityZonemay be undefinedStringAvailabilityZonemay be undefinedstringAvailabilityZonemay be undefined*string#blockDeviceMappingsmay be undefinedIResolvable | IResolvable | CfnInstance.BlockDeviceMappingProperty[]block_device_mappingsmay be undefinedtyping.Union[IResolvable, typing.List[typing.Union[IResolvable, BlockDeviceMappingProperty]]]blockDeviceMappingsmay be undefinedIResolvableBlockDeviceMappingsmay be undefinedIResolvableBlockDeviceMappingsmay be undefinedinterface{}#CFN_RESOURCE_TYPE_NAMEstringcfn_resource_type_namestrCFN_RESOURCE_TYPE_NAMEStringCFN_RESOURCE_TYPE_NAMEstringCFN_RESOURCE_TYPE_NAME*stringstatic#cfnOptionsICfnResourceOptionscfn_optionsICfnResourceOptionscfnOptionsICfnResourceOptionsCfnOptionsICfnResourceOptionsCfnOptionsICfnResourceOptions#cfnResourceTypestringcfn_resource_typestrcfnResourceTypeStringCfnResourceTypestringCfnResourceType*string#cpuOptionsmay be undefinedIResolvable | CfnInstance.CpuOptionsPropertycpu_optionsmay be undefinedtyping.Union[IResolvable, CpuOptionsProperty]cpuOptionsmay be undefinedIResolvableCpuOptionsmay be undefinedIResolvableCpuOptionsmay be undefinedinterface{}#creationStackstring[]creation_stacktyping.List[str]creationStackList<String>CreationStackstring[]CreationStack*[]*string#creditSpecificationmay be undefinedIResolvable | CfnInstance.CreditSpecificationPropertycredit_specificationmay be undefinedtyping.Union[IResolvable, CreditSpecificationProperty]creditSpecificationmay be undefinedIResolvableCreditSpecificationmay be undefinedIResolvableCreditSpecificationmay be undefinedinterface{}#disableApiTerminationmay be undefinedboolean | IResolvabledisable_api_terminationmay be undefinedtyping.Union[bool, IResolvable]disableApiTerminationmay be undefinedBooleanDisableApiTerminationmay be undefinedboolDisableApiTerminationmay be undefinedinterface{}#ebsOptimizedmay be undefinedboolean | IResolvableebs_optimizedmay be undefinedtyping.Union[bool, IResolvable]ebsOptimizedmay be undefinedBooleanEbsOptimizedmay be undefinedboolEbsOptimizedmay be undefinedinterface{}#elasticGpuSpecificationsmay be undefinedIResolvable | IResolvable | CfnInstance.ElasticGpuSpecificationProperty[]elastic_gpu_specificationsmay be undefinedtyping.Union[IResolvable, typing.List[typing.Union[IResolvable, ElasticGpuSpecificationProperty]]]elasticGpuSpecificationsmay be undefinedIResolvableElasticGpuSpecificationsmay be undefinedIResolvableElasticGpuSpecificationsmay be undefinedinterface{}#elasticInferenceAcceleratorsmay be undefinedIResolvable | IResolvable | CfnInstance.ElasticInferenceAcceleratorProperty[]elastic_inference_acceleratorsmay be undefinedtyping.Union[IResolvable, typing.List[typing.Union[IResolvable, ElasticInferenceAcceleratorProperty]]]elasticInferenceAcceleratorsmay be undefinedIResolvableElasticInferenceAcceleratorsmay be undefinedIResolvableElasticInferenceAcceleratorsmay be undefinedinterface{}#enclaveOptionsmay be undefinedIResolvable | CfnInstance.EnclaveOptionsPropertyenclave_optionsmay be undefinedtyping.Union[IResolvable, EnclaveOptionsProperty]enclaveOptionsmay be undefinedIResolvableEnclaveOptionsmay be undefinedIResolvableEnclaveOptionsmay be undefinedinterface{}#hibernationOptionsmay be undefinedIResolvable | CfnInstance.HibernationOptionsPropertyhibernation_optionsmay be undefinedtyping.Union[IResolvable, HibernationOptionsProperty]hibernationOptionsmay be undefinedIResolvableHibernationOptionsmay be undefinedIResolvableHibernationOptionsmay be undefinedinterface{}#hostIdmay be undefinedstringhost_idmay be undefinedstrhostIdmay be undefinedStringHostIdmay be undefinedstringHostIdmay be undefined*string#hostResourceGroupArnmay be undefinedstringhost_resource_group_arnmay be undefinedstrhostResourceGroupArnmay be undefinedStringHostResourceGroupArnmay be undefinedstringHostResourceGroupArnmay be undefined*string#iamInstanceProfilemay be undefinedstringiam_instance_profilemay be undefinedstriamInstanceProfilemay be undefinedStringIamInstanceProfilemay be undefinedstringIamInstanceProfilemay be undefined*string#imageIdmay be undefinedstringimage_idmay be undefinedstrimageIdmay be undefinedStringImageIdmay be undefinedstringImageIdmay be undefined*string#instanceInitiatedShutdownBehaviormay be undefinedstringinstance_initiated_shutdown_behaviormay be undefinedstrinstanceInitiatedShutdownBehaviormay be undefinedStringInstanceInitiatedShutdownBehaviormay be undefinedstringInstanceInitiatedShutdownBehaviormay be undefined*string#instanceRefInstanceReferenceinstance_refInstanceReferenceinstanceRefInstanceReferenceInstanceRefInstanceReferenceInstanceRefInstanceReference#instanceTypemay be undefinedstringinstance_typemay be undefinedstrinstanceTypemay be undefinedStringInstanceTypemay be undefinedstringInstanceTypemay be undefined*string#For more information, see Instance types in the Amazon EC2 User Guide .
ipv6AddressCountmay be undefinednumberipv6_address_countmay be undefinedint | floatipv6AddressCountmay be undefinedNumberIpv6AddressCountmay be undefineddoubleIpv6AddressCountmay be undefined*float64#ipv6Addressesmay be undefinedIResolvable | IResolvable | CfnInstance.InstanceIpv6AddressProperty[]ipv6_addressesmay be undefinedtyping.Union[IResolvable, typing.List[typing.Union[IResolvable, InstanceIpv6AddressProperty]]]ipv6Addressesmay be undefinedIResolvableIpv6Addressesmay be undefinedIResolvableIpv6Addressesmay be undefinedinterface{}#kernelIdmay be undefinedstringkernel_idmay be undefinedstrkernelIdmay be undefinedStringKernelIdmay be undefinedstringKernelIdmay be undefined*string#keyNamemay be undefinedstringkey_namemay be undefinedstrkeyNamemay be undefinedStringKeyNamemay be undefinedstringKeyNamemay be undefined*string#For more information, see Create a key pair for your EC2 instance .
launchTemplatemay be undefinedIResolvable | CfnInstance.LaunchTemplateSpecificationPropertylaunch_templatemay be undefinedtyping.Union[IResolvable, LaunchTemplateSpecificationProperty]launchTemplatemay be undefinedIResolvableLaunchTemplatemay be undefinedIResolvableLaunchTemplatemay be undefinedinterface{}#licenseSpecificationsmay be undefinedIResolvable | IResolvable | CfnInstance.LicenseSpecificationProperty[]license_specificationsmay be undefinedtyping.Union[IResolvable, typing.List[typing.Union[IResolvable, LicenseSpecificationProperty]]]licenseSpecificationsmay be undefinedIResolvableLicenseSpecificationsmay be undefinedIResolvableLicenseSpecificationsmay be undefinedinterface{}#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 | CfnInstance.MetadataOptionsPropertymetadata_optionsmay be undefinedtyping.Union[IResolvable, MetadataOptionsProperty]metadataOptionsmay be undefinedIResolvableMetadataOptionsmay be undefinedIResolvableMetadataOptionsmay be undefinedinterface{}#monitoringmay be undefinedboolean | IResolvablemonitoringmay be undefinedtyping.Union[bool, IResolvable]monitoringmay be undefinedBooleanMonitoringmay be undefinedboolMonitoringmay be undefinedinterface{}#networkInterfacesmay be undefinedIResolvable | IResolvable | CfnInstance.NetworkInterfaceProperty[]network_interfacesmay be undefinedtyping.Union[IResolvable, typing.List[typing.Union[IResolvable, NetworkInterfaceProperty]]]networkInterfacesmay be undefinedIResolvableNetworkInterfacesmay be undefinedIResolvableNetworkInterfacesmay be undefinedinterface{}#placementGroupNamemay be undefinedstringplacement_group_namemay be undefinedstrplacementGroupNamemay be undefinedStringPlacementGroupNamemay be undefinedstringPlacementGroupNamemay be undefined*string#privateDnsNameOptionsmay be undefinedIResolvable | CfnInstance.PrivateDnsNameOptionsPropertyprivate_dns_name_optionsmay be undefinedtyping.Union[IResolvable, PrivateDnsNameOptionsProperty]privateDnsNameOptionsmay be undefinedIResolvablePrivateDnsNameOptionsmay be undefinedIResolvablePrivateDnsNameOptionsmay be undefinedinterface{}#privateIpAddressmay be undefinedstringprivate_ip_addressmay be undefinedstrprivateIpAddressmay be undefinedStringPrivateIpAddressmay be undefinedstringPrivateIpAddressmay be undefined*string#You must specify a value from the IPv4 address range of the subnet.
propagateTagsToVolumeOnCreationmay be undefinedboolean | IResolvablepropagate_tags_to_volume_on_creationmay be undefinedtyping.Union[bool, IResolvable]propagateTagsToVolumeOnCreationmay be undefinedBooleanPropagateTagsToVolumeOnCreationmay be undefinedboolPropagateTagsToVolumeOnCreationmay be undefinedinterface{}#ramdiskIdmay be undefinedstringramdisk_idmay be undefinedstrramdiskIdmay be undefinedStringRamdiskIdmay be undefinedstringRamdiskIdmay be undefined*string#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 }).
securityGroupIdsmay be undefinedstring[]security_group_idsmay be undefinedtyping.List[str]securityGroupIdsmay be undefinedList<String>SecurityGroupIdsmay be undefinedstring[]SecurityGroupIdsmay be undefined*[]*string#securityGroupsmay be undefinedstring[]security_groupsmay be undefinedtyping.List[str]securityGroupsmay be undefinedList<String>SecurityGroupsmay be undefinedstring[]SecurityGroupsmay be undefined*[]*string#For a nondefault VPC, you must use security group IDs instead.
sourceDestCheckmay be undefinedboolean | IResolvablesource_dest_checkmay be undefinedtyping.Union[bool, IResolvable]sourceDestCheckmay be undefinedBooleanSourceDestCheckmay be undefinedboolSourceDestCheckmay be undefinedinterface{}#ssmAssociationsmay be undefinedIResolvable | IResolvable | CfnInstance.SsmAssociationProperty[]ssm_associationsmay be undefinedtyping.Union[IResolvable, typing.List[typing.Union[IResolvable, SsmAssociationProperty]]]ssmAssociationsmay be undefinedIResolvableSsmAssociationsmay be undefinedIResolvableSsmAssociationsmay be undefinedinterface{}#CfnElements must be defined within a stack scope (directly or indirectly).
subnetIdmay be undefinedstringsubnet_idmay be undefinedstrsubnetIdmay be undefinedStringSubnetIdmay be undefinedstringSubnetIdmay be undefined*string#tagsRawmay be undefinedCfnTag[]tags_rawmay be undefinedtyping.List[CfnTag]tagsRawmay be undefinedList<CfnTag>TagsRawmay be undefinedCfnTag[]TagsRawmay be undefined*[]CfnTag#tenancymay be undefinedstringtenancymay be undefinedstrtenancymay be undefinedStringTenancymay be undefinedstringTenancymay be undefined*string#userDatamay be undefinedstringuser_datamay be undefinedstruserDatamay be undefinedStringUserDatamay be undefinedstringUserDatamay be undefined*string#volumesmay be undefinedIResolvable | IResolvable | CfnInstance.VolumeProperty[]volumesmay be undefinedtyping.Union[IResolvable, typing.List[typing.Union[IResolvable, VolumeProperty]]]volumesmay be undefinedIResolvableVolumesmay be undefinedIResolvableVolumesmay be undefinedinterface{}#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)#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#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#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{})#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{})#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,
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.
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)#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{})#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)#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)#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)#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:
arnForInstance(resource: IInstanceRef): string@staticmethod def arn_for_instance(resource: IInstanceRef) -> strpublic static String arnForInstance(IInstanceRef resource)public static string ArnForInstance(IInstanceRef resource)func ArnForInstance(Resource IInstanceRef) *stringstatic#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#fromInstanceId(scope: Construct, id: string, instanceId: string): IInstanceRef@staticmethod def from_instance_id(scope: Construct, id: str, instance_id: str) -> IInstanceRefpublic static IInstanceRef fromInstanceId(Construct scope, String id, String instanceId)public static IInstanceRef FromInstanceId(Construct scope, string id, string instanceId)func FromInstanceId(Scope Construct, Id *string, InstanceId *string) IInstanceRefstatic#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#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{}#inspect(inspector: TreeInspector): voiddef inspect(self, inspector: TreeInspector) -> Nonepublic void inspect(TreeInspector inspector)public void Inspect(TreeInspector inspector)func Inspect(Inspector TreeInspector)#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#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.
isCfnInstance(x: any): boolean@staticmethod def is_cfn_instance(x: Any) -> boolpublic static Boolean isCfnInstance(Object x)public static bool IsCfnInstance(object x)func IsCfnInstance(X interface{}) *boolstatic#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#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#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{}#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)#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#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)#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)#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
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#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.