instances
Creates, updates, deletes, gets or lists an instances resource.
Overview
| Name | instances |
| Type | Resource |
| Id | aws.lightsail.instances |
Fields
The following fields are returned by SELECT queries:
- get_instance
- get_instances
| Name | Datatype | Description |
|---|---|---|
name | string | The name the user gave the instance (Amazon_Linux_2023-1). (pattern: <code>\w[\w-]*\w</code>) |
add_ons | array | An array of objects representing the add-ons enabled on the instance. |
arn | string | The Amazon Resource Name (ARN) of the instance (arn:aws:lightsail:us-east-2:123456789101:Instance/244ad76f-8aad-4741-809f-12345EXAMPLE). (pattern: <code>.\S.</code>) |
blueprint_id | string | The blueprint ID (amazon_linux_2023). (pattern: <code>.\S.</code>) |
blueprint_name | string | The friendly name of the blueprint (Amazon Linux 2023). (pattern: <code>.\S.</code>) |
bundle_id | string | The bundle for the instance (micro_x_x). (pattern: <code>.\S.</code>) |
created_at | string (date-time) | The timestamp when the instance was created (1479734909.17) in Unix time format. |
hardware | object | The size of the vCPU and the amount of RAM for the instance. |
ip_address_type | string | The IP address type of the instance. The possible values are ipv4 for IPv4 only, ipv6 for IPv6 only, and dualstack for IPv4 and IPv6. (dualstack, ipv4, ipv6) |
ipv_6_addresses | array | The IPv6 addresses of the instance. |
is_static_ip | boolean | A Boolean value indicating whether this instance has a static IP assigned to it. |
location | object | The region name and Availability Zone where the instance is located. |
metadata_options | object | The metadata options for the Amazon Lightsail instance. |
networking | object | Information about the public ports and monthly data transfer rates for the instance. |
private_ip_address | string | The private IP address of the instance. (pattern: <code>([0-9]{1,3}.){3}[0-9]{1,3}</code>) |
public_ip_address | string | The public IP address of the instance. (pattern: <code>([0-9]{1,3}.){3}[0-9]{1,3}</code>) |
resource_type | string | The type of resource (usually Instance). (ContainerService, Instance, StaticIp, KeyPair, InstanceSnapshot, Domain, PeeredVpc, LoadBalancer, LoadBalancerTlsCertificate, Disk, DiskSnapshot, RelationalDatabase, RelationalDatabaseSnapshot, ExportSnapshotRecord, CloudFormationStackRecord, Alarm, ContactMethod, Distribution, Certificate, Bucket) |
ssh_key_name | string | The name of the SSH key being used to connect to the instance (LightsailDefaultKeyPair). (pattern: <code>\w[\w-]*\w</code>) |
state | object | The status code and the state (running) for the instance. |
support_code | string | The support code. Include this code in your email to support when you have questions about an instance or another resource in Lightsail. This code enables our support team to look up your Lightsail information more easily. |
tags | array | The tag keys and optional values for the resource. For more information about tags in Lightsail, see the Amazon Lightsail Developer Guide. |
username | string | The user name for connecting to the instance (ec2-user). (pattern: <code>.\S.</code>) |
| Name | Datatype | Description |
|---|---|---|
name | string | The name the user gave the instance (Amazon_Linux_2023-1). (pattern: <code>\w[\w-]*\w</code>) |
add_ons | array | An array of objects representing the add-ons enabled on the instance. |
arn | string | The Amazon Resource Name (ARN) of the instance (arn:aws:lightsail:us-east-2:123456789101:Instance/244ad76f-8aad-4741-809f-12345EXAMPLE). (pattern: <code>.\S.</code>) |
blueprint_id | string | The blueprint ID (amazon_linux_2023). (pattern: <code>.\S.</code>) |
blueprint_name | string | The friendly name of the blueprint (Amazon Linux 2023). (pattern: <code>.\S.</code>) |
bundle_id | string | The bundle for the instance (micro_x_x). (pattern: <code>.\S.</code>) |
created_at | string (date-time) | The timestamp when the instance was created (1479734909.17) in Unix time format. |
hardware | object | The size of the vCPU and the amount of RAM for the instance. |
ip_address_type | string | The IP address type of the instance. The possible values are ipv4 for IPv4 only, ipv6 for IPv6 only, and dualstack for IPv4 and IPv6. (dualstack, ipv4, ipv6) |
ipv_6_addresses | array | The IPv6 addresses of the instance. |
is_static_ip | boolean | A Boolean value indicating whether this instance has a static IP assigned to it. |
location | object | The region name and Availability Zone where the instance is located. |
metadata_options | object | The metadata options for the Amazon Lightsail instance. |
networking | object | Information about the public ports and monthly data transfer rates for the instance. |
private_ip_address | string | The private IP address of the instance. (pattern: <code>([0-9]{1,3}.){3}[0-9]{1,3}</code>) |
public_ip_address | string | The public IP address of the instance. (pattern: <code>([0-9]{1,3}.){3}[0-9]{1,3}</code>) |
resource_type | string | The type of resource (usually Instance). (ContainerService, Instance, StaticIp, KeyPair, InstanceSnapshot, Domain, PeeredVpc, LoadBalancer, LoadBalancerTlsCertificate, Disk, DiskSnapshot, RelationalDatabase, RelationalDatabaseSnapshot, ExportSnapshotRecord, CloudFormationStackRecord, Alarm, ContactMethod, Distribution, Certificate, Bucket) |
ssh_key_name | string | The name of the SSH key being used to connect to the instance (LightsailDefaultKeyPair). (pattern: <code>\w[\w-]*\w</code>) |
state | object | The status code and the state (running) for the instance. |
support_code | string | The support code. Include this code in your email to support when you have questions about an instance or another resource in Lightsail. This code enables our support team to look up your Lightsail information more easily. |
tags | array | The tag keys and optional values for the resource. For more information about tags in Lightsail, see the Amazon Lightsail Developer Guide. |
username | string | The user name for connecting to the instance (ec2-user). (pattern: <code>.\S.</code>) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_instance | select | region | Returns information about a specific Amazon Lightsail instance, which is a virtual private server. | |
get_instances | select | region | Returns information about all Amazon Lightsail virtual private servers, or instances. | |
create_instances | insert | region, instanceNames, availabilityZone, blueprintId, bundleId | Creates one or more Amazon Lightsail instances. The create instances operation supports tag-based access control via request tags. For more information, see the Lightsail Developer Guide. | |
create_instances_from_snapshot | insert | region, instanceNames, availabilityZone, bundleId | Creates one or more new instances from a manual or automatic snapshot of an instance. The create instances from snapshot operation supports tag-based access control via request tags and resource tags applied to the resource identified by instance snapshot name. For more information, see the Amazon Lightsail Developer Guide. | |
setup_instance_https | update | region, instanceName, emailAddress, domainNames, certificateProvider | Creates an SSL/TLS certificate that secures traffic for your website. After the certificate is created, it is installed on the specified Lightsail instance. If you provide more than one domain name in the request, at least one name must be less than or equal to 63 characters in length. | |
update_instance_metadata_options | update | region, instanceName | Modifies the Amazon Lightsail instance metadata parameters on a running or stopped instance. When you modify the parameters on a running instance, the GetInstance or GetInstances API operation initially responds with a state of pending. After the parameter modifications are successfully applied, the state changes to applied in subsequent GetInstance or GetInstances API calls. For more information, see Use IMDSv2 with an Amazon Lightsail instance in the Amazon Lightsail Developer Guide. | |
put_instance_public_ports | replace | region, portInfos, instanceName | Opens ports for a specific Amazon Lightsail instance, and specifies the IP addresses allowed to connect to the instance through the ports, and the protocol. This action also closes all currently open ports that are not included in the request. Include all of the ports and the protocols you want to open in your PutInstancePublicPortsrequest. Or use the OpenInstancePublicPorts action to open ports without closing currently open ports. The PutInstancePublicPorts action supports tag-based access control via resource tags applied to the resource identified by instanceName. For more information, see the Amazon Lightsail Developer Guide. | |
delete_instance | delete | region | Deletes an Amazon Lightsail instance. The delete instance operation supports tag-based access control via resource tags applied to the resource identified by instance name. For more information, see the Amazon Lightsail Developer Guide. | |
close_instance_public_ports | exec | region, portInfo, instanceName | Closes ports for a specific Amazon Lightsail instance. The CloseInstancePublicPorts action supports tag-based access control via resource tags applied to the resource identified by instanceName. For more information, see the Amazon Lightsail Developer Guide. | |
delete_known_host_keys | exec | region, instanceName | Deletes the known host key or certificate used by the Amazon Lightsail browser-based SSH or RDP clients to authenticate an instance. This operation enables the Lightsail browser-based SSH or RDP clients to connect to the instance after a host key mismatch. Perform this operation only if you were expecting the host key or certificate mismatch or if you are familiar with the new host key or certificate on the instance. For more information, see Troubleshooting connection issues when using the Amazon Lightsail browser-based SSH or RDP client. | |
open_instance_public_ports | exec | region, portInfo, instanceName | Opens ports for a specific Amazon Lightsail instance, and specifies the IP addresses allowed to connect to the instance through the ports, and the protocol. The OpenInstancePublicPorts action supports tag-based access control via resource tags applied to the resource identified by instanceName. For more information, see the Amazon Lightsail Developer Guide. | |
reboot_instance | exec | region, instanceName | Restarts a specific instance. The reboot instance operation supports tag-based access control via resource tags applied to the resource identified by instance name. For more information, see the Amazon Lightsail Developer Guide. | |
start_instance | exec | region, instanceName | Starts a specific Amazon Lightsail instance from a stopped state. To restart an instance, use the reboot instance operation. When you start a stopped instance, Lightsail assigns a new public IP address to the instance. To use the same IP address after stopping and starting an instance, create a static IP address and attach it to the instance. For more information, see the Amazon Lightsail Developer Guide. The start instance operation supports tag-based access control via resource tags applied to the resource identified by instance name. For more information, see the Amazon Lightsail Developer Guide. | |
stop_instance | exec | region, instanceName | Stops a specific Amazon Lightsail instance that is currently running. When you start a stopped instance, Lightsail assigns a new public IP address to the instance. To use the same IP address after stopping and starting an instance, create a static IP address and attach it to the instance. For more information, see the Amazon Lightsail Developer Guide. The stop instance operation supports tag-based access control via resource tags applied to the resource identified by instance name. For more information, see the Amazon Lightsail Developer Guide. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
region | string | AWS region (default: us-east-1) |
SELECT examples
- get_instance
- get_instances
Returns information about a specific Amazon Lightsail instance, which is a virtual private server.
SELECT
name,
add_ons,
arn,
blueprint_id,
blueprint_name,
bundle_id,
created_at,
hardware,
ip_address_type,
ipv_6_addresses,
is_static_ip,
location,
metadata_options,
networking,
private_ip_address,
public_ip_address,
resource_type,
ssh_key_name,
state,
support_code,
tags,
username
FROM aws.lightsail.instances
WHERE region = '{{ region }}' -- required
;
Returns information about all Amazon Lightsail virtual private servers, or instances.
SELECT
name,
add_ons,
arn,
blueprint_id,
blueprint_name,
bundle_id,
created_at,
hardware,
ip_address_type,
ipv_6_addresses,
is_static_ip,
location,
metadata_options,
networking,
private_ip_address,
public_ip_address,
resource_type,
ssh_key_name,
state,
support_code,
tags,
username
FROM aws.lightsail.instances
WHERE region = '{{ region }}' -- required
;
INSERT examples
- create_instances
- create_instances_from_snapshot
- Manifest
Creates one or more Amazon Lightsail instances. The create instances operation supports tag-based access control via request tags. For more information, see the Lightsail Developer Guide.
INSERT INTO aws.lightsail.instances (
instanceNames,
availabilityZone,
customImageName,
blueprintId,
bundleId,
userData,
keyPairName,
tags,
addOns,
ipAddressType,
region
)
SELECT
'{{ instanceNames }}' /* required */,
'{{ availabilityZone }}' /* required */,
'{{ customImageName }}',
'{{ blueprintId }}' /* required */,
'{{ bundleId }}' /* required */,
'{{ userData }}',
'{{ keyPairName }}',
'{{ tags }}',
'{{ addOns }}',
'{{ ipAddressType }}',
'{{ region }}'
RETURNING
operations
;
Creates one or more new instances from a manual or automatic snapshot of an instance. The create instances from snapshot operation supports tag-based access control via request tags and resource tags applied to the resource identified by instance snapshot name. For more information, see the Amazon Lightsail Developer Guide.
INSERT INTO aws.lightsail.instances (
instanceNames,
attachedDiskMapping,
availabilityZone,
instanceSnapshotName,
bundleId,
userData,
keyPairName,
tags,
addOns,
ipAddressType,
sourceInstanceName,
restoreDate,
useLatestRestorableAutoSnapshot,
region
)
SELECT
'{{ instanceNames }}' /* required */,
'{{ attachedDiskMapping }}',
'{{ availabilityZone }}' /* required */,
'{{ instanceSnapshotName }}',
'{{ bundleId }}' /* required */,
'{{ userData }}',
'{{ keyPairName }}',
'{{ tags }}',
'{{ addOns }}',
'{{ ipAddressType }}',
'{{ sourceInstanceName }}',
'{{ restoreDate }}',
{{ useLatestRestorableAutoSnapshot }},
'{{ region }}'
RETURNING
operations
;
# Description fields are for documentation purposes
- name: instances
props:
- name: region
value: "{{ region }}"
description: Required parameter for the instances resource.
- name: instanceNames
value:
- "{{ instanceNames }}"
description: |
The names for your new instances.
- name: availabilityZone
value: "{{ availabilityZone }}"
description: |
The Availability Zone where you want to create your instances. Use the following formatting: us-east-2a (case sensitive). You can get a list of Availability Zones by using the get regions operation. Be sure to add the include Availability Zones parameter to your request.
- name: customImageName
value: "{{ customImageName }}"
description: |
(Discontinued) The name for your custom image. In releases prior to June 12, 2017, this parameter was ignored by the API. It is now discontinued.
- name: blueprintId
value: "{{ blueprintId }}"
description: |
The ID for a virtual private server image (app_wordpress_x_x or app_lamp_x_x). Use the get blueprints operation to return a list of available images (or blueprints). Use active blueprints when creating new instances. Inactive blueprints are listed to support customers with existing instances and are not necessarily available to create new instances. Blueprints are marked inactive when they become outdated due to operating system updates or new application releases.
- name: bundleId
value: "{{ bundleId }}"
description: |
The bundle of specification information for your virtual private server (or instance), including the pricing plan (micro_x_x).
- name: userData
value: "{{ userData }}"
description: |
You can create a launch script that configures a server with additional user data. For example, apt-get -y update. Depending on the machine image you choose, 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. For a complete list, see the Amazon Lightsail Developer Guide.
- name: keyPairName
value: "{{ keyPairName }}"
description: |
The name for your key pair.
- name: tags
description: |
The tag keys and optional values to add to the resource during create. Use the TagResource action to tag a resource after it's created.
value:
- key: "{{ key }}"
value: "{{ value }}"
- name: addOns
description: |
An array of objects representing the add-ons to enable for the new instance.
value:
- addOnType: "{{ addOnType }}"
autoSnapshotAddOnRequest:
snapshotTimeOfDay: "{{ snapshotTimeOfDay }}"
stopInstanceOnIdleRequest:
threshold: "{{ threshold }}"
duration: "{{ duration }}"
- name: ipAddressType
value: "{{ ipAddressType }}"
description: |
The IP address type for the instance. The possible values are ipv4 for IPv4 only, ipv6 for IPv6 only, and dualstack for IPv4 and IPv6. The default value is dualstack.
valid_values: ['dualstack', 'ipv4', 'ipv6']
- name: attachedDiskMapping
value: "{{ attachedDiskMapping }}"
description: |
An object containing information about one or more disk mappings.
- name: instanceSnapshotName
value: "{{ instanceSnapshotName }}"
description: |
The name of the instance snapshot on which you are basing your new instances. Use the get instance snapshots operation to return information about your existing snapshots. Constraint: This parameter cannot be defined together with the source instance name parameter. The instance snapshot name and source instance name parameters are mutually exclusive.
- name: sourceInstanceName
value: "{{ sourceInstanceName }}"
description: |
The name of the source instance from which the source automatic snapshot was created. Constraints: This parameter cannot be defined together with the instance snapshot name parameter. The source instance name and instance snapshot name parameters are mutually exclusive. Define this parameter only when creating a new instance from an automatic snapshot. For more information, see the Amazon Lightsail Developer Guide.
- name: restoreDate
value: "{{ restoreDate }}"
description: |
The date of the automatic snapshot to use for the new instance. Use the get auto snapshots operation to identify the dates of the available automatic snapshots. Constraints: Must be specified in YYYY-MM-DD format. This parameter cannot be defined together with the use latest restorable auto snapshot parameter. The restore date and use latest restorable auto snapshot parameters are mutually exclusive. Define this parameter only when creating a new instance from an automatic snapshot. For more information, see the Amazon Lightsail Developer Guide.
- name: useLatestRestorableAutoSnapshot
value: {{ useLatestRestorableAutoSnapshot }}
description: |
A Boolean value to indicate whether to use the latest available automatic snapshot. Constraints: This parameter cannot be defined together with the restore date parameter. The use latest restorable auto snapshot and restore date parameters are mutually exclusive. Define this parameter only when creating a new instance from an automatic snapshot. For more information, see the Amazon Lightsail Developer Guide.
UPDATE examples
- setup_instance_https
- update_instance_metadata_options
Creates an SSL/TLS certificate that secures traffic for your website. After the certificate is created, it is installed on the specified Lightsail instance. If you provide more than one domain name in the request, at least one name must be less than or equal to 63 characters in length.
UPDATE aws.lightsail.instances
SET
instanceName = '{{ instanceName }}',
emailAddress = '{{ emailAddress }}',
domainNames = '{{ domainNames }}',
certificateProvider = '{{ certificateProvider }}'
WHERE
region = '{{ region }}' --required
AND instanceName = '{{ instanceName }}' --required
AND emailAddress = '{{ emailAddress }}' --required
AND domainNames = '{{ domainNames }}' --required
AND certificateProvider = '{{ certificateProvider }}' --required
RETURNING
operations;
Modifies the Amazon Lightsail instance metadata parameters on a running or stopped instance. When you modify the parameters on a running instance, the GetInstance or GetInstances API operation initially responds with a state of pending. After the parameter modifications are successfully applied, the state changes to applied in subsequent GetInstance or GetInstances API calls. For more information, see Use IMDSv2 with an Amazon Lightsail instance in the Amazon Lightsail Developer Guide.
UPDATE aws.lightsail.instances
SET
instanceName = '{{ instanceName }}',
httpTokens = '{{ httpTokens }}',
httpEndpoint = '{{ httpEndpoint }}',
httpPutResponseHopLimit = {{ httpPutResponseHopLimit }},
httpProtocolIpv6 = '{{ httpProtocolIpv6 }}'
WHERE
region = '{{ region }}' --required
AND instanceName = '{{ instanceName }}' --required
RETURNING
operation;
REPLACE examples
- put_instance_public_ports
Opens ports for a specific Amazon Lightsail instance, and specifies the IP addresses allowed to connect to the instance through the ports, and the protocol. This action also closes all currently open ports that are not included in the request. Include all of the ports and the protocols you want to open in your PutInstancePublicPortsrequest. Or use the OpenInstancePublicPorts action to open ports without closing currently open ports. The PutInstancePublicPorts action supports tag-based access control via resource tags applied to the resource identified by instanceName. For more information, see the Amazon Lightsail Developer Guide.
REPLACE aws.lightsail.instances
SET
portInfos = '{{ portInfos }}',
instanceName = '{{ instanceName }}'
WHERE
region = '{{ region }}' --required
AND portInfos = '{{ portInfos }}' --required
AND instanceName = '{{ instanceName }}' --required
RETURNING
operation;
DELETE examples
- delete_instance
Deletes an Amazon Lightsail instance. The delete instance operation supports tag-based access control via resource tags applied to the resource identified by instance name. For more information, see the Amazon Lightsail Developer Guide.
DELETE FROM aws.lightsail.instances
WHERE region = '{{ region }}' --required
;
Lifecycle Methods
- close_instance_public_ports
- delete_known_host_keys
- open_instance_public_ports
- reboot_instance
- start_instance
- stop_instance
Closes ports for a specific Amazon Lightsail instance. The CloseInstancePublicPorts action supports tag-based access control via resource tags applied to the resource identified by instanceName. For more information, see the Amazon Lightsail Developer Guide.
EXEC aws.lightsail.instances.close_instance_public_ports
@region='{{ region }}' --required
@@json=
'{
"portInfo": "{{ portInfo }}",
"instanceName": "{{ instanceName }}"
}'
;
Deletes the known host key or certificate used by the Amazon Lightsail browser-based SSH or RDP clients to authenticate an instance. This operation enables the Lightsail browser-based SSH or RDP clients to connect to the instance after a host key mismatch. Perform this operation only if you were expecting the host key or certificate mismatch or if you are familiar with the new host key or certificate on the instance. For more information, see Troubleshooting connection issues when using the Amazon Lightsail browser-based SSH or RDP client.
EXEC aws.lightsail.instances.delete_known_host_keys
@region='{{ region }}' --required
@@json=
'{
"instanceName": "{{ instanceName }}"
}'
;
Opens ports for a specific Amazon Lightsail instance, and specifies the IP addresses allowed to connect to the instance through the ports, and the protocol. The OpenInstancePublicPorts action supports tag-based access control via resource tags applied to the resource identified by instanceName. For more information, see the Amazon Lightsail Developer Guide.
EXEC aws.lightsail.instances.open_instance_public_ports
@region='{{ region }}' --required
@@json=
'{
"portInfo": "{{ portInfo }}",
"instanceName": "{{ instanceName }}"
}'
;
Restarts a specific instance. The reboot instance operation supports tag-based access control via resource tags applied to the resource identified by instance name. For more information, see the Amazon Lightsail Developer Guide.
EXEC aws.lightsail.instances.reboot_instance
@region='{{ region }}' --required
@@json=
'{
"instanceName": "{{ instanceName }}"
}'
;
Starts a specific Amazon Lightsail instance from a stopped state. To restart an instance, use the reboot instance operation. When you start a stopped instance, Lightsail assigns a new public IP address to the instance. To use the same IP address after stopping and starting an instance, create a static IP address and attach it to the instance. For more information, see the Amazon Lightsail Developer Guide. The start instance operation supports tag-based access control via resource tags applied to the resource identified by instance name. For more information, see the Amazon Lightsail Developer Guide.
EXEC aws.lightsail.instances.start_instance
@region='{{ region }}' --required
@@json=
'{
"instanceName": "{{ instanceName }}"
}'
;
Stops a specific Amazon Lightsail instance that is currently running. When you start a stopped instance, Lightsail assigns a new public IP address to the instance. To use the same IP address after stopping and starting an instance, create a static IP address and attach it to the instance. For more information, see the Amazon Lightsail Developer Guide. The stop instance operation supports tag-based access control via resource tags applied to the resource identified by instance name. For more information, see the Amazon Lightsail Developer Guide.
EXEC aws.lightsail.instances.stop_instance
@region='{{ region }}' --required
@@json=
'{
"instanceName": "{{ instanceName }}",
"force": {{ force }}
}'
;