Last active
January 27, 2020 22:39
-
-
Save tfolbrecht/fd84627113ebf129cc90520410484cde to your computer and use it in GitHub Desktop.
Self Terminate EC2
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 | |
| # *WARNING* This is a fragile solution, if the bash script fails, hangs, etc, the shutdown won't execute. | |
| # Set am asynchronous kill job above the execution of this script with a sensible timeout | |
| # example bash ec2seppuku.sh & sleep 60 && shutdown -h now | |
| # Also set up aws logging, and clean up your aws env periodically just in case | |
| # ¯\_(ツ)_/¯ | |
| # launch with --instance-initiated-shutdown-behavior terminate so it cleans up | |
| if command; then | |
| echo "" | |
| else | |
| echo "Some failure occured" | |
| fi | |
| shutdown -h now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment