Running user-data Post Spin Up (Linux)

Ok, first post is going to be quick and easy.  It’s been a while since I said I would post something and when I ran across this I figured I would start adding content to the site.

Let’s assume the following:

  1. You built an environment using CloudFormation or by hand and gave your instance user-data to run.  In this case, it was to install OpenVPN on an Ubuntu server.
  2. Your Security Groups were designed by someone who knew what they were doing but you forgot to attach the one that allows outbound on 80 which prevented the server from installing OpenVPN.
  3. You have fixed your Security Group issue and you have full ssh access to the server and rather not rebuild – you just want to re-run the user-data.

Here is an option.  I am by no means saying this is your only option, but it works and it was simple to do.

  1. Log in using ssh with your pem key.
  2. Run the following:
sudo curl >/usr/local/bin/
sudo chmod +x /usr/local/bin/
  1. Complete your OpenVPN configuration (sudo passwd openvpn, etc…)

What this does is grab your current user-data from the self hosted site on your EC2 instance, copies it to a local bash file, gives that file execute permission and then runs it.

Voila!  Your user-data now ran properly.

For more information using on using local meta-data and user-data please the AWS documentation @

Happy Building!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.