1

I am trying to figure out the best way to do this on AWS. What I want to do is:

I want to launch an EC2 instance using my custom AMI but on launch make some custom configurations to the environment. I want to:

  • Checkout some git repos.
  • Create a few php files with content i specify in a folder in my docroot.
  • Install composer on one of the repos.
  • Modify the https.conf docroot to a specific folder.

Can this all be done in the launch configuration? What would be a best practice for accomplishing this?

1 Answer 1

4

This is precisely what EC2's user data functionality is for.

You can provide a shell script that makes your required changes, or even better than that, have the system pull its intended configuration from your Configuration Management solution (Ansible, Salt, etc.).

2
  • Yeah, this is very helpful. One thing that is still unclear is how I can modify the DocumentRoot "/var/www/html" in the httpd.conf. Basically I want to checkout a repo into /var/www/html and then modify the apache https.conf to point to a new DocumentRoot. Commented Aug 28, 2015 at 15:42
  • 2
    You use whatever standard unix stream editor you want to make the change (sed, awk, etc.). This is where a configuration management system can shine - deploying templatized configuration files that are filled out uniquely on a per-system basis. Commented Aug 28, 2015 at 18:42

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.