# ok
# how-to loop trough all your load balancer names
while read -r lb ; do \
echo -e "\n\n start lb: $lb " ; \
aws elb add-tags --load-balancer-name $lb --tags \
"Key=Team,Value=odinId-834" \
"Key=ODINAPPID_ENV_ROLE_STACK,Value=834_dev_app_nps" \
--profile dev; \
echo " stop lb: $lb" ; \
done < <(aws elb describe-load-balancers --query \
'LoadBalancerDescriptions[].LoadBalancerName' \
--profile dev|perl -nle 's/\s+/\n/g;print')
# how-to loop trough all your lb instances
while read -r lb ; do \
echo -e "\n\n start lb: $lb " ; \
echo run cmd on lb: $lb ; \
echo " stop lb: $lb" ; \
done < <(aws elb describe-load-balancers --query \
'LoadBalancerDescriptions[].Instances[].InstanceId' \
--profile dev|perl -nle 's/\s+/\n/g;print')
# how-to query all the instance id's in <<env>>
while read -r i ; do echo instance-id: $i; done < <(aws ec2 describe-instances --query "Reservations[].Instances[].InstanceId" --profile dev|perl -nl -e 's/\s+/\n/g;print')
# how-to list the tags in the instances
for i in $(aws ec2 describe-instances --query "Reservations[].Instances[].InstanceId" --profile prd) ; do echo instance $i tags : ; aws ec2 describe-tags --filters "Name=resource-id,Values=$i" --profile prd --output table ; done ;
# how-to add tags to all instances in env
for i in $(aws ec2 describe-instances --query "Reservations[].Instances[].InstanceId" --profile dev) ; do echo -e "instance $i :\n" ; aws ec2 create-tags --resources $i --tags "Key=TheKey,Value=TheValue" --profile dev ; echo -e "stop instance : $i \n" ; done ;
# add the ODINAPPID_ENV_ROLE_STACK tag to all the istances in dev
for i in $(aws ec2 describe-instances --query "Reservations[].Instances[].InstanceId" --profile dev) ; do echo -e "instance $i :\n" ; aws ec2 create-tags --resources $i --tags "Key=ODINAPPID_ENV_ROLE_STACK,Value=834_dev_app_nps" --profile dev ; echo -e "stop instance : $i \n" ; done ;
# add the Team tag to all the instances in prd
for i in $(aws ec2 describe-instances --query "Reservations[].Instances[].InstanceId" --profile prd) ; do echo -e "instance $i :\n" ; aws ec2 create-tags --resources $i --tags "Key=Team,Value=odinId-834" --profile prd ; echo -e "stop instance : $i \n" ; done ;
for i in $(aws ec2 describe-instances --query \
"Reservations[].Instances[].InstanceId" --profile prd) ; do \
echo instance $i tags : ; aws ec2 describe-tags \
--filters "Name=resource-id,Values=$i" \
--profile prd --output table | egrep -i 'team' ; \
done
while read -r i ; do
echo instance-id: $i ;
done < <(aws ec2 describe-instances --query \
"Reservations[].Instances[].InstanceId" --profile dev) ;
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!