How to make EC2 user data script run again on startup?

By default, user data scripts and cloud-init directives run only during the first boot cycle when an EC2 instance is launched. However, you can configure your user data script and cloud-init directives with a mime multi-part file. A mime multi-part file allows your script to override how frequently user data is run in the cloud-init package.

Step 1: Stop the EC2 instance

Step 2: Click Actions > Instance settings > Edit user data
Update your EC2 instance user data with the below content.
Make sure to replace /bin/echo “your start-up script” with the actual script that you want to execute.

Now the above user data will get executed every time your EC2 instance starts up.

Leave a Reply