Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added instances start and stop script
- Loading branch information
1 parent
47104b4
commit 723e69c
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
for instance_id in $(aws ec2 describe-instances --filters "Name=tag:Env,Values=test" --query "Reservations[].Instances[].InstanceId" --output text) | ||
do | ||
echo "stopping instance with instance id ${instance_id}" | ||
aws ec2 stop-instances --instance-ids ${instance_id} | ||
sleep 1s | ||
curent_state=$(aws ec2 describe-instances --instance-ids ${instance_id} --query "Reservations[].Instances[].State.Name|[0]" --output text) | ||
echo "The current state is ${curent_state} for ec2 instance with id ${instance_id}" | ||
done | ||
|
||
# for instance_id in $(aws ec2 describe-instances --filters "Name=tag:Env,Values=test" --query "Reservations[].Instances[].InstanceId" --output text) | ||
# do | ||
# echo "stopping instance with instance id ${instance_id}" | ||
# aws ec2 start-instances --instance-ids ${instance_id} | ||
# sleep 1s | ||
# curent_state=$(aws ec2 describe-instances --instance-ids ${instance_id} --query "Reservations[].Instances[].State.Name|[0]" --output text) | ||
# echo "The current state is ${curent_state} for ec2 instance with id ${instance_id}" | ||
# done |