Skip to content
v2.278.0

CfnInstance L1 construct ​

The AWS::Lightsail::Instance resource specifies an Amazon Lightsail instance.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_lightsail as lightsail } from 'aws-cdk-lib';
const cfnInstance = new lightsail.CfnInstance(this, 'MyCfnInstance', {
  blueprintId: 'blueprintId',
  bundleId: 'bundleId',
  instanceName: 'instanceName',

  // the properties below are optional
  addOns: [{
    addOnType: 'addOnType',

    // the properties below are optional
    autoSnapshotAddOnRequest: {
      snapshotTimeOfDay: 'snapshotTimeOfDay',
    },
    status: 'status',
  }],
  availabilityZone: 'availabilityZone',
  hardware: {
    cpuCount: 123,
    disks: [{
      diskName: 'diskName',
      path: 'path',

      // the properties below are optional
      attachedTo: 'attachedTo',
      attachmentState: 'attachmentState',
      iops: 123,
      isSystemDisk: false,
      sizeInGb: 'sizeInGb',
    }],
    ramSizeInGb: 123,
  },
  keyPairName: 'keyPairName',
  location: {
    availabilityZone: 'availabilityZone',
    regionName: 'regionName',
  },
  networking: {
    ports: [{
      accessDirection: 'accessDirection',
      accessFrom: 'accessFrom',
      accessType: 'accessType',
      cidrListAliases: ['cidrListAliases'],
      cidrs: ['cidrs'],
      commonName: 'commonName',
      fromPort: 123,
      ipv6Cidrs: ['ipv6Cidrs'],
      protocol: 'protocol',
      toPort: 123,
    }],

    // the properties below are optional
    monthlyTransfer: {
      gbPerMonthAllocated: 'gbPerMonthAllocated',
    },
  },
  state: {
    code: 123,
    name: 'name',
  },
  tags: [{
    key: 'key',
    value: 'value',
  }],
  userData: 'userData',
});
python
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_lightsail as lightsail

cfn_instance = lightsail.CfnInstance(self, "MyCfnInstance",
    blueprint_id="blueprintId",
    bundle_id="bundleId",
    instance_name="instanceName",

    # the properties below are optional
    add_ons=[lightsail.CfnInstance.AddOnProperty(
        add_on_type="addOnType",

        # the properties below are optional
        auto_snapshot_add_on_request=lightsail.CfnInstance.AutoSnapshotAddOnProperty(
            snapshot_time_of_day="snapshotTimeOfDay"
        ),
        status="status"
    )],
    availability_zone="availabilityZone",
    hardware=lightsail.CfnInstance.HardwareProperty(
        cpu_count=123,
        disks=[lightsail.CfnInstance.DiskProperty(
            disk_name="diskName",
            path="path",

            # the properties below are optional
            attached_to="attachedTo",
            attachment_state="attachmentState",
            iops=123,
            is_system_disk=False,
            size_in_gb="sizeInGb"
        )],
        ram_size_in_gb=123
    ),
    key_pair_name="keyPairName",
    location=lightsail.CfnInstance.LocationProperty(
        availability_zone="availabilityZone",
        region_name="regionName"
    ),
    networking=lightsail.CfnInstance.NetworkingProperty(
        ports=[lightsail.CfnInstance.PortProperty(
            access_direction="accessDirection",
            access_from="accessFrom",
            access_type="accessType",
            cidr_list_aliases=["cidrListAliases"],
            cidrs=["cidrs"],
            common_name="commonName",
            from_port=123,
            ipv6_cidrs=["ipv6Cidrs"],
            protocol="protocol",
            to_port=123
        )],

        # the properties below are optional
        monthly_transfer=lightsail.CfnInstance.MonthlyTransferProperty(
            gb_per_month_allocated="gbPerMonthAllocated"
        )
    ),
    state=lightsail.CfnInstance.StateProperty(
        code=123,
        name="name"
    ),
    tags=[CfnTag(
        key="key",
        value="value"
    )],
    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.lightsail.*;

CfnInstance cfnInstance = CfnInstance.Builder.create(this, "MyCfnInstance")
        .blueprintId("blueprintId")
        .bundleId("bundleId")
        .instanceName("instanceName")

        // the properties below are optional
        .addOns(List.of(AddOnProperty.builder()
                .addOnType("addOnType")

                // the properties below are optional
                .autoSnapshotAddOnRequest(AutoSnapshotAddOnProperty.builder()
                        .snapshotTimeOfDay("snapshotTimeOfDay")
                        .build())
                .status("status")
                .build()))
        .availabilityZone("availabilityZone")
        .hardware(HardwareProperty.builder()
                .cpuCount(123)
                .disks(List.of(DiskProperty.builder()
                        .diskName("diskName")
                        .path("path")

                        // the properties below are optional
                        .attachedTo("attachedTo")
                        .attachmentState("attachmentState")
                        .iops(123)
                        .isSystemDisk(false)
                        .sizeInGb("sizeInGb")
                        .build()))
                .ramSizeInGb(123)
                .build())
        .keyPairName("keyPairName")
        .location(LocationProperty.builder()
                .availabilityZone("availabilityZone")
                .regionName("regionName")
                .build())
        .networking(NetworkingProperty.builder()
                .ports(List.of(PortProperty.builder()
                        .accessDirection("accessDirection")
                        .accessFrom("accessFrom")
                        .accessType("accessType")
                        .cidrListAliases(List.of("cidrListAliases"))
                        .cidrs(List.of("cidrs"))
                        .commonName("commonName")
                        .fromPort(123)
                        .ipv6Cidrs(List.of("ipv6Cidrs"))
                        .protocol("protocol")
                        .toPort(123)
                        .build()))

                // the properties below are optional
                .monthlyTransfer(MonthlyTransferProperty.builder()
                        .gbPerMonthAllocated("gbPerMonthAllocated")
                        .build())
                .build())
        .state(StateProperty.builder()
                .code(123)
                .name("name")
                .build())
        .tags(List.of(CfnTag.builder()
                .key("key")
                .value("value")
                .build()))
        .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.Lightsail;

var cfnInstance = new CfnInstance(this, "MyCfnInstance", new CfnInstanceProps {
    BlueprintId = "blueprintId",
    BundleId = "bundleId",
    InstanceName = "instanceName",

    // the properties below are optional
    AddOns = new [] { new AddOnProperty {
        AddOnType = "addOnType",

        // the properties below are optional
        AutoSnapshotAddOnRequest = new AutoSnapshotAddOnProperty {
            SnapshotTimeOfDay = "snapshotTimeOfDay"
        },
        Status = "status"
    } },
    AvailabilityZone = "availabilityZone",
    Hardware = new HardwareProperty {
        CpuCount = 123,
        Disks = new [] { new DiskProperty {
            DiskName = "diskName",
            Path = "path",

            // the properties below are optional
            AttachedTo = "attachedTo",
            AttachmentState = "attachmentState",
            Iops = 123,
            IsSystemDisk = false,
            SizeInGb = "sizeInGb"
        } },
        RamSizeInGb = 123
    },
    KeyPairName = "keyPairName",
    Location = new LocationProperty {
        AvailabilityZone = "availabilityZone",
        RegionName = "regionName"
    },
    Networking = new NetworkingProperty {
        Ports = new [] { new PortProperty {
            AccessDirection = "accessDirection",
            AccessFrom = "accessFrom",
            AccessType = "accessType",
            CidrListAliases = new [] { "cidrListAliases" },
            Cidrs = new [] { "cidrs" },
            CommonName = "commonName",
            FromPort = 123,
            Ipv6Cidrs = new [] { "ipv6Cidrs" },
            Protocol = "protocol",
            ToPort = 123
        } },

        // the properties below are optional
        MonthlyTransfer = new MonthlyTransferProperty {
            GbPerMonthAllocated = "gbPerMonthAllocated"
        }
    },
    State = new StateProperty {
        Code = 123,
        Name = "name"
    },
    Tags = new [] { new CfnTag {
        Key = "key",
        Value = "value"
    } },
    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"

cfnInstance := awscdk.Aws_lightsail.NewCfnInstance(this, jsii.String("MyCfnInstance"), &CfnInstanceProps{
	BlueprintId: jsii.String("blueprintId"),
	BundleId: jsii.String("bundleId"),
	InstanceName: jsii.String("instanceName"),

	// the properties below are optional
	AddOns: []interface{}{
		&AddOnProperty{
			AddOnType: jsii.String("addOnType"),

			// the properties below are optional
			AutoSnapshotAddOnRequest: &AutoSnapshotAddOnProperty{
				SnapshotTimeOfDay: jsii.String("snapshotTimeOfDay"),
			},
			Status: jsii.String("status"),
		},
	},
	AvailabilityZone: jsii.String("availabilityZone"),
	Hardware: &HardwareProperty{
		CpuCount: jsii.Number(123),
		Disks: []interface{}{
			&DiskProperty{
				DiskName: jsii.String("diskName"),
				Path: jsii.String("path"),

				// the properties below are optional
				AttachedTo: jsii.String("attachedTo"),
				AttachmentState: jsii.String("attachmentState"),
				Iops: jsii.Number(123),
				IsSystemDisk: jsii.Boolean(false),
				SizeInGb: jsii.String("sizeInGb"),
			},
		},
		RamSizeInGb: jsii.Number(123),
	},
	KeyPairName: jsii.String("keyPairName"),
	Location: &LocationProperty{
		AvailabilityZone: jsii.String("availabilityZone"),
		RegionName: jsii.String("regionName"),
	},
	Networking: &NetworkingProperty{
		Ports: []interface{}{
			&PortProperty{
				AccessDirection: jsii.String("accessDirection"),
				AccessFrom: jsii.String("accessFrom"),
				AccessType: jsii.String("accessType"),
				CidrListAliases: []*string{
					jsii.String("cidrListAliases"),
				},
				Cidrs: []*string{
					jsii.String("cidrs"),
				},
				CommonName: jsii.String("commonName"),
				FromPort: jsii.Number(123),
				Ipv6Cidrs: []*string{
					jsii.String("ipv6Cidrs"),
				},
				Protocol: jsii.String("protocol"),
				ToPort: jsii.Number(123),
			},
		},

		// the properties below are optional
		MonthlyTransfer: &MonthlyTransferProperty{
			GbPerMonthAllocated: jsii.String("gbPerMonthAllocated"),
		},
	},
	State: &StateProperty{
		Code: jsii.Number(123),
		Name: jsii.String("name"),
	},
	Tags: []CfnTag{
		&CfnTag{
			Key: jsii.String("key"),
			Value: jsii.String("value"),
		},
	},
	UserData: jsii.String("userData"),
})

Initializer ​

ts
new CfnInstance(scope: Construct, id: string, props: CfnInstanceProps)
python
CfnInstance(scope: Construct, id: str, props: CfnInstanceProps)
java
new CfnInstance(Construct scope, String id, CfnInstanceProps props)
csharp
new CfnInstance(Construct scope, string id, CfnInstanceProps props)
go
NewCfnInstance(Scope Construct, Id *string, Props CfnInstanceProps)

Construct Props ​

addOnsoptionalIResolvable | IResolvable | CfnInstance.AddOnProperty[]add_onsoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, AddOnProperty]]]addOnsoptionalIResolvableAddOnsoptionalIResolvableAddOnsoptionalinterface{} #
An array of add-ons for the instance.

If the instance has an add-on enabled when performing a delete instance request, the add-on is automatically disabled before the instance is deleted.

availabilityZoneoptionalstringavailability_zoneoptionalstravailabilityZoneoptionalStringAvailabilityZoneoptionalstringAvailabilityZoneoptional*string #
The Availability Zone for the instance.
blueprintIdstringblueprint_idstrblueprintIdStringBlueprintIdstringBlueprintId*string required #
The blueprint ID for the instance (for example, `os_amlinux_2016_03` ).
bundleIdstringbundle_idstrbundleIdStringBundleIdstringBundleId*string required #
The bundle ID for the instance (for example, `micro_1_0` ).
hardwareoptionalIResolvable | CfnInstance.HardwarePropertyhardwareoptionaltyping.Union[IResolvable, HardwareProperty]hardwareoptionalIResolvableHardwareoptionalIResolvableHardwareoptionalinterface{} #
The hardware properties for the instance, such as the vCPU count, attached disks, and amount of RAM.

The instance restarts when performing an attach disk or detach disk request. This resets the public IP address of your instance if a static IP isn't attached to it.

instanceNamestringinstance_namestrinstanceNameStringInstanceNamestringInstanceName*string required #
The name of the instance.
keyPairNameoptionalstringkey_pair_nameoptionalstrkeyPairNameoptionalStringKeyPairNameoptionalstringKeyPairNameoptional*string #
The name of the key pair to use for the instance.

If no key pair name is specified, the Regional Lightsail default key pair is used.

locationoptionalIResolvable | CfnInstance.LocationPropertylocationoptionaltyping.Union[IResolvable, LocationProperty]locationoptionalIResolvableLocationoptionalIResolvableLocationoptionalinterface{} #
The location for the instance, such as the AWS Region and Availability Zone.

The Location property is read-only and should not be specified in a create instance or update instance request.

networkingoptionalIResolvable | CfnInstance.NetworkingPropertynetworkingoptionaltyping.Union[IResolvable, NetworkingProperty]networkingoptionalIResolvableNetworkingoptionalIResolvableNetworkingoptionalinterface{} #
The public ports and the monthly amount of data transfer allocated for the instance.
stateoptionalIResolvable | CfnInstance.StatePropertystateoptionaltyping.Union[IResolvable, StateProperty]stateoptionalIResolvableStateoptionalIResolvableStateoptionalinterface{} #
The status code and the state (for example, `running` ) of the instance.

The State property is read-only and should not be specified in a create instance or update instance request.

tagsoptionalCfnTag[]tagsoptionaltyping.List[CfnTag]tagsoptionalList<CfnTag>TagsoptionalCfnTag[]Tagsoptional*[]CfnTag #
An array of key-value pairs to apply to this resource.

For more information, see Tag in the AWS CloudFormation User Guide .

The Value of Tags is optional for Lightsail resources.

userDataoptionalstringuser_dataoptionalstruserDataoptionalStringUserDataoptionalstringUserDataoptional*string #
The optional launch script for the instance.
notes

Specify a launch script to configure an instance with additional user data. For example, you might want to specify apt-get -y update as a launch script.

Depending on the blueprint of your instance, the command to get software on your instance varies. Amazon Linux and CentOS use yum , Debian and Ubuntu use apt-get , and FreeBSD uses pkg .

Properties ​

addOnsmay be undefinedIResolvable | IResolvable | CfnInstance.AddOnProperty[]add_onsmay be undefinedtyping.Union[IResolvable, typing.List[typing.Union[IResolvable, AddOnProperty]]]addOnsmay be undefinedIResolvableAddOnsmay be undefinedIResolvableAddOnsmay be undefinedinterface{} #
An array of add-ons for the instance.
attrHardwareCpuCountnumberattr_hardware_cpu_countint | floatattrHardwareCpuCountNumberAttrHardwareCpuCountdoubleAttrHardwareCpuCount*float64 #
The number of vCPUs the instance has.
attrHardwareRamSizeInGbnumberattr_hardware_ram_size_in_gbint | floatattrHardwareRamSizeInGbNumberAttrHardwareRamSizeInGbdoubleAttrHardwareRamSizeInGb*float64 #
The amount of RAM in GB on the instance (for example, `1.0` ).
attrInstanceArnstringattr_instance_arnstrattrInstanceArnStringAttrInstanceArnstringAttrInstanceArn*string #
The Amazon Resource Name (ARN) of the instance (for example, `arn:aws:lightsail:us-east-2:123456789101:Instance/244ad76f-8aad-4741-809f-12345EXAMPLE` ).
attrIpv6Addressesstring[]attr_ipv6_addressestyping.List[str]attrIpv6AddressesList<String>AttrIpv6Addressesstring[]AttrIpv6Addresses*[]*string #
The IPv6 addresses of the instance.
attrIsStaticIpIResolvableattr_is_static_ipIResolvableattrIsStaticIpIResolvableAttrIsStaticIpIResolvableAttrIsStaticIpIResolvable #
A Boolean value indicating whether the instance has a static IP assigned to it.
attrLocationAvailabilityZonestringattr_location_availability_zonestrattrLocationAvailabilityZoneStringAttrLocationAvailabilityZonestringAttrLocationAvailabilityZone*string #
The AWS Region and Availability Zone where the instance is located.
attrLocationRegionNamestringattr_location_region_namestrattrLocationRegionNameStringAttrLocationRegionNamestringAttrLocationRegionName*string #
The AWS Region of the instance.
attrNetworkingMonthlyTransferGbPerMonthAllocatedstringattr_networking_monthly_transfer_gb_per_month_allocatedstrattrNetworkingMonthlyTransferGbPerMonthAllocatedStringAttrNetworkingMonthlyTransferGbPerMonthAllocatedstringAttrNetworkingMonthlyTransferGbPerMonthAllocated*string #
The amount of allocated monthly data transfer (in GB) for an instance.
attrPrivateIpAddressstringattr_private_ip_addressstrattrPrivateIpAddressStringAttrPrivateIpAddressstringAttrPrivateIpAddress*string #
The private IP address of the instance.
attrPublicIpAddressstringattr_public_ip_addressstrattrPublicIpAddressStringAttrPublicIpAddressstringAttrPublicIpAddress*string #
The public IP address of the instance.
attrResourceTypestringattr_resource_typestrattrResourceTypeStringAttrResourceTypestringAttrResourceType*string #
The resource type of the instance (for example, `Instance` ).
attrSshKeyNamestringattr_ssh_key_namestrattrSshKeyNameStringAttrSshKeyNamestringAttrSshKeyName*string #
The name of the SSH key pair used by the instance.
attrStateCodenumberattr_state_codeint | floatattrStateCodeNumberAttrStateCodedoubleAttrStateCode*float64 #
The status code of the instance.
attrStateNamestringattr_state_namestrattrStateNameStringAttrStateNamestringAttrStateName*string #
The state of the instance (for example, `running` or `pending` ).
attrSupportCodestringattr_support_codestrattrSupportCodeStringAttrSupportCodestringAttrSupportCode*string #
The support code of the instance.

Include this code in your email to support when you have questions about an instance or another resource in Lightsail . This code helps our support team to look up your Lightsail information.

attrUserNamestringattr_user_namestrattrUserNameStringAttrUserNamestringAttrUserName*string #
The user name for connecting to the instance (for example, `ec2-user` ).
availabilityZonemay be undefinedstringavailability_zonemay be undefinedstravailabilityZonemay be undefinedStringAvailabilityZonemay be undefinedstringAvailabilityZonemay be undefined*string #
The Availability Zone for the instance.
blueprintIdstringblueprint_idstrblueprintIdStringBlueprintIdstringBlueprintId*string #
The blueprint ID for the instance (for example, `os_amlinux_2016_03` ).
bundleIdstringbundle_idstrbundleIdStringBundleIdstringBundleId*string #
The bundle ID for the instance (for example, `micro_1_0` ).
CFN_RESOURCE_TYPE_NAMEstringCFN_RESOURCE_TYPE_NAMEstrCFN_RESOURCE_TYPE_NAMEStringCFN_RESOURCE_TYPE_NAMEstringCFN_RESOURCE_TYPE_NAME*string static #
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.
creationStackstring[]creation_stacktyping.List[str]creationStackList<String>CreationStackstring[]CreationStack*[]*string #
hardwaremay be undefinedIResolvable | CfnInstance.HardwarePropertyhardwaremay be undefinedtyping.Union[IResolvable, HardwareProperty]hardwaremay be undefinedIResolvableHardwaremay be undefinedIResolvableHardwaremay be undefinedinterface{} #
The hardware properties for the instance, such as the vCPU count, attached disks, and amount of RAM.
instanceNamestringinstance_namestrinstanceNameStringInstanceNamestringInstanceName*string #
The name of the instance.
A reference to a Instance resource.
keyPairNamemay be undefinedstringkey_pair_namemay be undefinedstrkeyPairNamemay be undefinedStringKeyPairNamemay be undefinedstringKeyPairNamemay be undefined*string #
The name of the key pair to use for the instance.
locationmay be undefinedIResolvable | CfnInstance.LocationPropertylocationmay be undefinedtyping.Union[IResolvable, LocationProperty]locationmay be undefinedIResolvableLocationmay be undefinedIResolvableLocationmay be undefinedinterface{} #
The location for the instance, such as the AWS Region and Availability Zone.
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).

networkingmay be undefinedIResolvable | CfnInstance.NetworkingPropertynetworkingmay be undefinedtyping.Union[IResolvable, NetworkingProperty]networkingmay be undefinedIResolvableNetworkingmay be undefinedIResolvableNetworkingmay be undefinedinterface{} #
The public ports and the monthly amount of data transfer allocated for the instance.
nodeNodenodeNodenodeNodeNodeNodeNodeNode #
The tree node.
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 }).

stackStackstackStackstackStackStackStackStackStack #
The stack in which this element is defined.

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

statemay be undefinedIResolvable | CfnInstance.StatePropertystatemay be undefinedtyping.Union[IResolvable, StateProperty]statemay be undefinedIResolvableStatemay be undefinedIResolvableStatemay be undefinedinterface{} #
The status code and the state (for example, `running` ) of the instance.
Tag Manager which manages the tags for this resource.
tagsRawmay be undefinedCfnTag[]tags_rawmay be undefinedtyping.List[CfnTag]tagsRawmay be undefinedList<CfnTag>TagsRawmay be undefinedCfnTag[]TagsRawmay be undefined*[]CfnTag #
An array of key-value pairs to apply to this resource.
userDatamay be undefinedstringuser_datamay be undefinedstruserDatamay be undefinedStringUserDatamay be undefinedstringUserDatamay be undefined*string #
The optional launch script for the instance.

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:

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) *string static #
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{}) *bool static #
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.

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{}) *bool static #
Checks whether the given object is a CfnInstance.
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{}) *bool static #
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{}) *bool static #
Checks if `x` is a construct.
notes · 1 parameter · returns

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

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

Parameters

  • xxxxX — Any object.

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

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.