Last active
July 23, 2016 05:37
-
-
Save seventhskye/9a99c5e0cb623b9d1cc77fe6758fed68 to your computer and use it in GitHub Desktop.
A script to collect InstanceIds from AWS by a tag: ScheduledUptime in this case. The list can then be used for other tasks such as shutting down instances.
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 | |
# 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 start-instances --instance-ids $IDS --output text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment