Skip to content

Instantly share code, notes, and snippets.

@seventhskye
Last active July 23, 2016 05:37
Show Gist options
  • Save seventhskye/5e5d20f59e951fc62b49ef35458c87eb to your computer and use it in GitHub Desktop.
Save seventhskye/5e5d20f59e951fc62b49ef35458c87eb to your computer and use it in GitHub Desktop.
A script to turn all instances off.
#!/bin/bash
# The TAG_KEY and TAG_VALUE environment variables
# can be set before running the script otherwise the
# default are used.
IDS`aws ec2 describe-instances \
--filter "Name=tag:${TAG_KEY:-ScheduledUptime},Values=${TAG_VALUE:-True}" \
--query 'Reservations[*].Instances[*].[InstanceId]' \
--output text`
aws ec2 stop-instances --instance-ids $IDS --output text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment