-
Notifications
You must be signed in to change notification settings - Fork 0
/
aws-cli.sh
27 lines (20 loc) · 989 Bytes
/
aws-cli.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
echo -n 'Enter Name Where Scaling Groups will be updated: "Default Stack" = ' -e -i 'Test ' ; read stackname
scalegroups=($(aws autoscaling describe-auto-scaling-groups \
--query 'AutoScalingGroups[?contains(Tags[?Key==`aws:cloudformation:stack-name`].Value, `'$stackname'`)].AutoScalingGroupName' \
--output text))
echo "Total Stacks Found :" ${scalegroups[*]}
for group in "${scalegroups[@]//,/}"
do
echo "Processing group: $group"
currentcapacity=$(aws autoscaling describe-auto-scaling-groups \
--query 'AutoScalingGroups[?AutoScalingGroupName==`'$group'`].DesiredCapacity' \
--output text)
aws autoscaling set-desired-capacity \
--auto-scaling-group-name $group \
--desired-capacity $((currentcapacity + 1)) \
--honor-cooldown
latestcapacity=$(aws autoscaling describe-auto-scaling-groups \
--query 'AutoScalingGroups[?AutoScalingGroupName==`'$group'`].DesiredCapacity' \
--output text)
echo "Latest Capacity = " $latestcapacity
done