volume_attachments
Creates, updates, deletes or gets a volume_attachment
resource or lists volume_attachments
in a region
Overview
Name | volume_attachments |
Type | Resource |
Description | Attaches an Amazon EBS volume to a running instance and exposes it to the instance with the specified device name. Before this resource can be deleted (and therefore the volume detached), you must first unmount the volume in the instance. Failure to do so results in the volume being stuck in the busy state while it is trying to detach, which could possibly damage the file system or the data it contains. If an Amazon EBS volume is the root device of an instance, it cannot be detached while the instance is in the "running" state. To detach the root volume, stop the instance first. If the root volume is detached from an instance with an MKT product code, then the product codes from that volume are no longer associated with the instance. |
Id | aws.ec2.volume_attachments |
Fields
Name | Datatype | Description |
---|---|---|
volume_id | string | The ID of the Amazon EBS volume. The volume and instance must be within the same Availability Zone. This value can be a reference to an [AWS::EC2::Volume](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-ebs-volume.html) resource, or it can be the volume ID of an existing Amazon EBS volume. |
instance_id | string | The ID of the instance to which the volume attaches. This value can be a reference to an [AWS::EC2::Instance](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html) resource, or it can be the physical ID of an existing EC2 instance. |
device | string | The device name (for example, /dev/sdh or xvdh ). |
region | string | AWS region. |
Methods
Name | Accessible by | Required Params |
---|---|---|
create_resource | INSERT | VolumeId, InstanceId, region |
delete_resource | DELETE | data__Identifier, region |
list_resources | SELECT | region |
get_resource | SELECT | data__Identifier, region |
SELECT
examples
Gets all volume_attachments
in a region.
SELECT
region,
volume_id,
instance_id,
device
FROM aws.ec2.volume_attachments
WHERE region = 'us-east-1';
Gets all properties from an individual volume_attachment
.
SELECT
region,
volume_id,
instance_id,
device
FROM aws.ec2.volume_attachments
WHERE region = 'us-east-1' AND data__Identifier = '<VolumeId>|<InstanceId>';
INSERT
example
Use the following StackQL query and manifest file to create a new volume_attachment
resource, using stack-deploy
.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO aws.ec2.volume_attachments (
VolumeId,
InstanceId,
region
)
SELECT
'{{ VolumeId }}',
'{{ InstanceId }}',
'{{ region }}';
/*+ create */
INSERT INTO aws.ec2.volume_attachments (
VolumeId,
InstanceId,
Device,
region
)
SELECT
'{{ VolumeId }}',
'{{ InstanceId }}',
'{{ Device }}',
'{{ region }}';
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: volume_attachment
props:
- name: VolumeId
value: '{{ VolumeId }}'
- name: InstanceId
value: '{{ InstanceId }}'
- name: Device
value: '{{ Device }}'
DELETE
example
/*+ delete */
DELETE FROM aws.ec2.volume_attachments
WHERE data__Identifier = '<VolumeId|InstanceId>'
AND region = 'us-east-1';
Permissions
To operate on the volume_attachments
resource, the following permissions are required:
Create
ec2:AttachVolume,
ec2:DescribeVolumes
Read
ec2:DescribeVolumes
Delete
ec2:DetachVolume,
ec2:DescribeVolumes
List
ec2:DescribeVolumes