Skip to main content

disks

Creates, updates, deletes, gets or lists a disks resource.

Overview

Namedisks
TypeResource
Idaws.lightsail.disks

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringThe unique name of the disk. (pattern: <code>\w[\w-]*\w</code>)
add_onsarrayAn array of objects representing the add-ons enabled on the disk.
arnstringThe Amazon Resource Name (ARN) of the disk. (pattern: <code>.\S.</code>)
attached_tostringThe resources to which the disk is attached. (pattern: <code>\w[\w-]*\w</code>)
attachment_statestring(Discontinued) The attachment state of the disk. In releases prior to November 14, 2017, this parameter returned attached for system disks in the API response. It is now discontinued, but still included in the response. Use isAttached instead.
auto_mount_statusstringThe status of automatically mounting a storage disk to a virtual computer. This parameter only applies to Lightsail for Research resources. (Failed, Pending, Mounted, NotMounted)
created_atstring (date-time)The date when the disk was created.
gb_in_useinteger(Discontinued) The number of GB in use by the disk. In releases prior to November 14, 2017, this parameter was not included in the API response. It is now discontinued.
iopsintegerThe input/output operations per second (IOPS) of the disk.
is_attachedbooleanA Boolean value indicating whether the disk is attached.
is_system_diskbooleanA Boolean value indicating whether this disk is a system disk (has an operating system loaded on it).
locationobjectThe AWS Region and Availability Zone where the disk is located.
pathstringThe disk path.
resource_typestringThe Lightsail resource type (Disk). (ContainerService, Instance, StaticIp, KeyPair, InstanceSnapshot, Domain, PeeredVpc, LoadBalancer, LoadBalancerTlsCertificate, Disk, DiskSnapshot, RelationalDatabase, RelationalDatabaseSnapshot, ExportSnapshotRecord, CloudFormationStackRecord, Alarm, ContactMethod, Distribution, Certificate, Bucket)
size_in_gbintegerThe size of the disk in GB.
statestringDescribes the status of the disk. (pending, error, available, in-use, unknown)
support_codestringThe 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.
tagsarrayThe tag keys and optional values for the resource. For more information about tags in Lightsail, see the Amazon Lightsail Developer Guide.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_diskselectregionReturns information about a specific block storage disk.
get_disksselectregionReturns information about all block storage disks in your AWS account and region.
create_diskinsertregion, diskName, availabilityZone, sizeInGbCreates a block storage disk that can be attached to an Amazon Lightsail instance in the same Availability Zone (us-east-2a). The create disk operation supports tag-based access control via request tags. For more information, see the Amazon Lightsail Developer Guide.
attach_diskupdateregion, diskName, instanceName, diskPathAttaches a block storage disk to a running or stopped Lightsail instance and exposes it to the instance with the specified disk name. The attach disk operation supports tag-based access control via resource tags applied to the resource identified by disk name. For more information, see the Amazon Lightsail Developer Guide.
detach_diskupdateregion, diskNameDetaches a stopped block storage disk from a Lightsail instance. Make sure to unmount any file systems on the device within your operating system before stopping the instance and detaching the disk. The detach disk operation supports tag-based access control via resource tags applied to the resource identified by disk name. For more information, see the Amazon Lightsail Developer Guide.
delete_diskdeleteregionDeletes the specified block storage disk. The disk must be in the available state (not attached to a Lightsail instance). The disk may remain in the deleting state for several minutes. The delete disk operation supports tag-based access control via resource tags applied to the resource identified by disk name. For more information, see the Amazon Lightsail Developer Guide.
create_disk_from_snapshotexecregion, diskName, availabilityZone, sizeInGbCreates a block storage disk from a manual or automatic snapshot of a disk. The resulting disk can be attached to an Amazon Lightsail instance in the same Availability Zone (us-east-2a). The create disk from snapshot operation supports tag-based access control via request tags and resource tags applied to the resource identified by disk snapshot 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.

NameDatatypeDescription
regionstringAWS region (default: us-east-1)

SELECT examples

Returns information about a specific block storage disk.

SELECT
name,
add_ons,
arn,
attached_to,
attachment_state,
auto_mount_status,
created_at,
gb_in_use,
iops,
is_attached,
is_system_disk,
location,
path,
resource_type,
size_in_gb,
state,
support_code,
tags
FROM aws.lightsail.disks
WHERE region = '{{ region }}' -- required
;

INSERT examples

Creates a block storage disk that can be attached to an Amazon Lightsail instance in the same Availability Zone (us-east-2a). The create disk operation supports tag-based access control via request tags. For more information, see the Amazon Lightsail Developer Guide.

INSERT INTO aws.lightsail.disks (
diskName,
availabilityZone,
sizeInGb,
tags,
addOns,
region
)
SELECT
'{{ diskName }}' /* required */,
'{{ availabilityZone }}' /* required */,
{{ sizeInGb }} /* required */,
'{{ tags }}',
'{{ addOns }}',
'{{ region }}'
RETURNING
operations
;

UPDATE examples

Attaches a block storage disk to a running or stopped Lightsail instance and exposes it to the instance with the specified disk name. The attach disk operation supports tag-based access control via resource tags applied to the resource identified by disk name. For more information, see the Amazon Lightsail Developer Guide.

UPDATE aws.lightsail.disks
SET
diskName = '{{ diskName }}',
instanceName = '{{ instanceName }}',
diskPath = '{{ diskPath }}',
autoMounting = {{ autoMounting }}
WHERE
region = '{{ region }}' --required
AND diskName = '{{ diskName }}' --required
AND instanceName = '{{ instanceName }}' --required
AND diskPath = '{{ diskPath }}' --required
RETURNING
operations;

DELETE examples

Deletes the specified block storage disk. The disk must be in the available state (not attached to a Lightsail instance). The disk may remain in the deleting state for several minutes. The delete disk operation supports tag-based access control via resource tags applied to the resource identified by disk name. For more information, see the Amazon Lightsail Developer Guide.

DELETE FROM aws.lightsail.disks
WHERE region = '{{ region }}' --required
;

Lifecycle Methods

Creates a block storage disk from a manual or automatic snapshot of a disk. The resulting disk can be attached to an Amazon Lightsail instance in the same Availability Zone (us-east-2a). The create disk from snapshot operation supports tag-based access control via request tags and resource tags applied to the resource identified by disk snapshot name. For more information, see the Amazon Lightsail Developer Guide.

EXEC aws.lightsail.disks.create_disk_from_snapshot
@region='{{ region }}' --required
@@json=
'{
"diskName": "{{ diskName }}",
"diskSnapshotName": "{{ diskSnapshotName }}",
"availabilityZone": "{{ availabilityZone }}",
"sizeInGb": {{ sizeInGb }},
"tags": "{{ tags }}",
"addOns": "{{ addOns }}",
"sourceDiskName": "{{ sourceDiskName }}",
"restoreDate": "{{ restoreDate }}",
"useLatestRestorableAutoSnapshot": {{ useLatestRestorableAutoSnapshot }}
}'
;