Created
May 19, 2015 13:36
-
-
Save franklanganke/f00db2aa016ee21c76cf to your computer and use it in GitHub Desktop.
Stop EC2 instances by tag
This file contains hidden or 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
#!/bin/bash | |
# 19.05.2015 Frank Langanke | |
# stop ec2 instances by tag "off-time" with value "true", can be used as cronjob | |
PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/bin | |
_instances=$(aws ec2 describe-instances --filters "Name=tag:off-time,Values=true" --query Reservations[].Instances[].[InstanceId] --output text) | |
aws ec2 stop-instances --instance-ids $_instances |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment