Skip to content
v2.277.0

CfnInstanceProps Struct ​

Properties for defining a CfnInstance.

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 cfnInstanceProps: lightsail.CfnInstanceProps = {
  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_props = lightsail.CfnInstanceProps(
    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.*;

CfnInstanceProps cfnInstanceProps = CfnInstanceProps.builder()
        .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 cfnInstanceProps = 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"

cfnInstanceProps := &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"),
}

Properties ​

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*stringrequired#
The blueprint ID for the instance (for example, `os_amlinux_2016_03` ).
bundleIdstringbundle_idstrbundleIdStringBundleIdstringBundleId*stringrequired#
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*stringrequired#
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 .