Skip to content

Instantly share code, notes, and snippets.

@evandhoffman
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evandhoffman/c22f0f3b9cfe8c906fbf to your computer and use it in GitHub Desktop.
Save evandhoffman/c22f0f3b9cfe8c906fbf to your computer and use it in GitHub Desktop.
Tag all EBS volumes in a VPC

Get list of instances in the VPC:

[evan@Evan ~] $ aws ec2 describe-instances --filter Name=vpc-id,Values=vpc-id | jq '[.Reservations[] | .Instances[] | .InstanceId ] | join(",")'

Get the list of volumes attached to those instances:

[evan@Evan ~] $ aws ec2 describe-volumes --filters Name=attachment.instance-id,Values=i-abcd,i-abce,i-abcf,i-abcg

Paste result into this command:

[evan@Evan ~] $ aws ec2 create-tags --tags Key=environment,Value=production --resources vol-abcd vol-abce vol-abcf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment