EC2 userdata script not working
Note that user data scripts run only during the first boot cycle when an EC2 instance is launched. This is the default behaviour and not an issue.
It's possible to configure user data script with a mime multi-part file which will run on every boot cycle.
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
touch /root/userdata_test.txt
--//
This is the sample code and we need to replace "touch /root/user_test.txt" with the required commands or scripts.
That's all…