0

In AWS CLI I am trying to get the ec2 volume "Attachment Information"

I see how I can find the Instance information, but this does not include the Attachment Information. The information I am looking for can actually be found in the ec2 Volume Management Console, but I want to use CLI to list it as text so I can put it in a text file. Is this possible.

aws ec2 describe-volumes --output text --region us-east-1 <-- doesn't show the attachment information of the instance description.

http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-volumes.html

UPDATE: The above command does output the attachment information "i-1234567" but NOT the Instance Description. Example i-1234567 (AWSServer)

2

The attachment information is included in the describe-volumes function.

aws ec2 describe-volumes --output text --region us-east-1 includes a section called ATTACHMENTS (if attached), such as the following:

VOLUMES us-east-1a      2016-03-22T23:00:54.577Z        False   300     100    available        vol-12345678    gp2
TAGS    backup  yes
VOLUMES us-east-1d      2015-12-08T21:24:25.007Z        False   24      8      snap-12345678    in-use  vol-12345678    gp2
ATTACHMENTS     2015-12-08T21:24:25.000Z        True    /dev/xvda       i-12345678      attached        vol-12345678

The above example shows two volumes, one attached and one not attached.

The ATTACHMENTS section includes the date of attachment, the "Delete on Terminate" flag, device name, attached EC2 instance, and status.

Update:

In the AWS Console, the "Attachment Information" column displays the EC2 intance ID and the "Name" tag from the EC2 instance. The "Name" tag is not included in the results from describe-volumes.

To get the "Name" tag, you'll need to call aws ec2 describe-instances. Either a blanket call to get all EC2 instances, or by including the --instance-id parameter to get the EC2 instance you care about. The response from describe-instances includes the tags.

  • Correct and thats what I have. I figured out the disconnect. In the Attachment information we inputted a description. Its that description that is not showing. So for example i-12345678 (AWSServer). Thats what I want listed. Updating my question. Thanks! – Benjamin Jones May 17 '16 at 16:21
  • I have updated my answer. – Matt Houser May 17 '16 at 16:49

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.