Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50d0ac9
commit 2ad90ad
Showing
1 changed file
with
7 additions
and
2 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 |
---|---|---|
@@ -1,5 +1,10 @@ | ||
#!/bin/bash | ||
|
||
instanceIds=$(aws ec2 describe-instances --filters "Name=tag:Env,Values=QA" "Name=instance-state-name,Values=running" --query "Reservations[].Instances[].InstanceId" --output text) | ||
echo "The instance ids which will be shutdown are ${instanceIds}" | ||
aws ec2 stop-instances --instance-ids ${instanceIds} | ||
|
||
if [[ -n $instanceIds ]]; then | ||
echo "The instance ids which will be shutdown are ${instanceIds}" | ||
aws ec2 stop-instances --instance-ids ${instanceIds} | ||
else | ||
echo "No instances found with matching criteria Env = QA" | ||
fi |