Created
February 23, 2022 22:48
-
-
Save chiefmikey/0c8d6b9c23a68bd3bb0875cdf6e02ecd to your computer and use it in GitHub Desktop.
AWS EC2 run a script on every instance start
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
# Select the AWS EC2 instance and change the state to stopped | |
# Go to Actions -> Instance settings -> Edit user data | |
# Paste this with your script and save | |
Content-Type: multipart/mixed; boundary="//" | |
MIME-Version: 1.0 | |
--// | |
Content-Type: text/cloud-config; charset="us-ascii" | |
MIME-Version: 1.0 | |
Content-Transfer-Encoding: 7bit | |
Content-Disposition: attachment; filename="cloud-config.txt" | |
#cloud-config | |
cloud_final_modules: | |
- [scripts-user, always] | |
--// | |
Content-Type: text/x-shellscript; charset="us-ascii" | |
MIME-Version: 1.0 | |
Content-Transfer-Encoding: 7bit | |
Content-Disposition: attachment; filename="userdata.txt" | |
#!/bin/bash | |
# Your script goes here | |
--//-- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment