Skip to content

Instantly share code, notes, and snippets.

@nagataka
Last active December 20, 2015 11:48
Show Gist options
  • Save nagataka/6125786 to your computer and use it in GitHub Desktop.
Save nagataka/6125786 to your computer and use it in GitHub Desktop.
create EC2 instance with adding arbitrary number of tags to attached EBS volume.
#!/bin/sh
if [ "$1" = "" ]
then
echo usage $0 key=value [[key=value] ... ]
exit 0
else
instance=`ec2-run-instances ami-39b23d38 | awk '{print $2}' | grep i-`
sleep 3
volume=`ec2-describe-volumes | grep $instance | awk '{print $2}'`
for vol in ${volume[@]}; do
while [ "$1" != "" ]; do
ec2-create-tags "$vol" --tag "$1"
shift
done
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment