Add a specific tag to EC2 instances?

COUNTER=0
for instance_id in `aws ec2 describe-instances --query "Reservations[*].Instances[*].{Instance:InstanceId}"  --filters "Name=tag:Name,Values=*<Common_name>*"  --output text --region <region_name>`
do
let COUNTER++
printf $COUNTER;
echo ". Setting up tag for the instance "$instance_id;
aws ec2 create-tags --resources $instance_id --region
<region_name>  --tags "Key"="<key_that_needs_to_be_added>","Value"="<value_that_needs_to_be_added>" ;
done;

Comments

Popular posts from this blog

Logical volume vmxxxx_img is used by another device - Error on LVM removal

Open VZ cheat Sheet

Cheat sheet for Hardware RAID health check - Megaraid, Adaptec, 3wareraid and HPraid.