DEV Community

Discussion on: Easily Rerun EC2 UserData

Collapse
ferricoxide profile image
Thomas H Jones II

No need to curl, the userData content is stored under /var/lib/cloud/instances/. Depending how you structured your userData (e.g., if you only had a simple #!/bin/bash), the immediately-executable script content will be stored in /var/lib/cloud/instances/scripts/part-001. Meaning all you really need to do to re-run it is SSH into the host and do sudo bash var/lib/cloud/instances/scripts/part-001.

Things get a bit more complex if you've used multipart-MIME userData, but the underlying logic is similar.

Similarly, if you want to reboot your instance and have it rerun userData automatically, simply rm -rf var/lib/cloud/instances/<INSTANCE_ID>

Collapse
denolfe profile image
Elliot DeNolf Author

Good stuff, thanks!