How do you find the EBS Volume IDS for a Volume that was created and attached at EC2 Instance Launch Time ?


When Creating and Attaching an EBS Volume at RunInstances time, the CreateVolume and AttachVolume CloudTrail entries are missing. I don't see any CloudTrail entries that are related to the created volume until we do a snapshot, then detach, then delete. Once the instance is running, if we create a second EBS Volume, and attach it, snapshot it, detach it, and then delete the volume, we what you would expect, which is CreateVolume -> AttachVolume -> CreateSnapshot -> DetachVolume -> DeleteVolume in the CloudTrail Logs.

When we look at the RunInstances event for the instance creation, there is no reference to the EBS Volume Id that was create during instance run time. My question is, is there any way to find all EBS volumes that are attached to a running EC2 instance when those EBS Volumes were created and attached at instance run time by using CloudTrail logs ?

We can see the volume information in the RunInstances JSON for the instance launch :

{ "deviceName": "/dev/sdb", "ebs": { "volumeSize": 5, "deleteOnTermination": true, "volumeType": "gp3", "iops": 3000, "throughput": 125 } } But again, there is no reference to the actual volume-id .

Thanks for any pointers !

asked 2 years ago1476 views
1 Answer

Using the AWS CLI, you can use the Describe-Volume operation by passing the attached EC2 Instance ID as a filter to find ALL volumes attached to it.

Check out example 2 on in the CLI reference which is similar to what you are asking:

answered 2 years ago
  • Thank you, so if I read this correctly, it means that there is no way to find this without specifically querying for it , which is to say it will not show up in the logs due to the way it was created, you will have to go look for it, correct ?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions