AWS::Lightsail::Instance - AWS CloudFormation

AWS::Lightsail::Instance

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

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::Lightsail::Instance", "Properties" : { "AddOns" : [ AddOn, ... ], "AvailabilityZone" : String, "BlueprintId" : String, "BundleId" : String, "Hardware" : Hardware, "InstanceName" : String, "KeyPairName" : String, "Networking" : Networking, "Tags" : [ Tag, ... ], "UserData" : String } }

YAML

Type: AWS::Lightsail::Instance Properties: AddOns: - AddOn AvailabilityZone: String BlueprintId: String BundleId: String Hardware: Hardware InstanceName: String KeyPairName: String Networking: Networking Tags: - Tag UserData: String

Properties

AddOns

An array of add-ons for the instance.

Note

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.

Required: No

Type: List of AddOn

Update requires: No interruption

AvailabilityZone

The Availability Zone for the instance.

Required: No

Type: String

Update requires: Updates are not supported.

BlueprintId

The blueprint ID for the instance (for example, os_amlinux_2016_03).

Required: Yes

Type: String

Update requires: Updates are not supported.

BundleId

The bundle ID for the instance (for example, micro_1_0).

Required: Yes

Type: String

Update requires: Updates are not supported.

Hardware

The hardware properties for the instance, such as the vCPU count, attached disks, and amount of RAM.

Important

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.

Required: No

Type: Hardware

Update requires: Some interruptions

InstanceName

The name of the instance.

Required: Yes

Type: String

Pattern: \w[\w\-]*\w

Update requires: Replacement

KeyPairName

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.

Required: No

Type: String

Update requires: No interruption

Networking

The public ports and the monthly amount of data transfer allocated for the instance.

Required: No

Type: Networking

Update requires: No interruption

Tags

An array of key-value pairs to apply to this resource.

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

Note

The Value of Tags is optional for Lightsail resources.

Required: No

Type: List of Tag

Update requires: No interruption

UserData

The optional launch script for the instance.

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.

Note

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.

Required: No

Type: String

Update requires: No interruption

Return values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns a unique identifier for this resource.

Fn::GetAtt

The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.

Hardware.CpuCount

The number of vCPUs the instance has.

Hardware.RamSizeInGb

The amount of RAM in GB on the instance (for example, 1.0).

InstanceArn

The Amazon Resource Name (ARN) of the instance (for example, arn:aws:lightsail:us-east-2:123456789101:Instance/244ad76f-8aad-4741-809f-12345EXAMPLE).

IsStaticIp

A Boolean value indicating whether the instance has a static IP assigned to it.

Location.AvailabilityZone

The AWS Region and Availability Zone where the instance is located.

Location.RegionName

The AWS Region of the instance.

Networking.MonthlyTransfer.GbPerMonthAllocated

The amount of allocated monthly data transfer (in GB) for an instance.

PrivateIpAddress

The private IP address of the instance.

PublicIpAddress

The public IP address of the instance.

ResourceType

The resource type of the instance (for example, Instance).

SshKeyName

The name of the SSH key pair used by the instance.

State.Code

The status code of the instance.

State.Name

The state of the instance (for example, running or pending).

SupportCode

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.

UserName

The user name for connecting to the instance (for example, ec2-user).

Remarks

Attaching a static IP to an instance

You cannot attach a static IP to an instance using the instance resource. Instead, you must use the static IP resource to attach a static IP to an instance. To attach a static IP to an instance, the instance must be in a running state.

Network ports

If no network ports are specified when performing a create instance request, the default network ports are opened when the instance is created.

To open ports on your instance when performing a create instance request, you must specify all the ports that you want to open, including the default ports. The default ports are not automatically opened when you specify the ports you want to open.

Disk attach and detach

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.

If you detach a disk (for eample, DiskA) and attach a different disk (for example, DiskB) in the same request, and the attach disk request fails, AWS CloudFormation will attempt to roll back the changes so that DiskA is re-attached to the instance. However, if you delete DiskA before AWS CloudFormation attemps the roll-back, then the roll-back will fail and the instance will not have either disk attached.

Read-only properties

The State, Location, CpuCount, and RamSizeInGb properties are read-only and should not be specified in a create instance or update instance request.