Terraform Modules for one line server setup

This is a guide for the advanced users but it actually simplifies server setup into a few commands you can run from your terminal / command line.

I make use of an app called Terraform (http://terraform.io) which lets me setup 1 or many servers in a single command. I use these to setup our dev and live servers on Dream Compute even if they be a single server only.

Cloud servers have to be thought of as ephemeral and will eventually die, if you need to upgrade or change something, you change your configuration and start new servers. I have come to this conclusion after repeatedly setting up the same servers over and over again. Its not like VPS or dedicated servers where you can upgrade and restore from a backup if something goes wrong.

Anyway these are the Terraform Modules I use to setup my servers, hopefully some people may find them useful:

CentOS 7 server running Apache, PHP5.6:

CentOS 7 server running MariaDB 10.1:

CentOS 7 server running Apache, PHP5.6, MariaDB 10.1:

Each one has a sample Terraform example in the README, they can be used to setup 1 server or many servers.

They each include a big provisioning script written in bash, so its configuration management agnostic and you can fork it and add/remove from it as you like.

My typical setup involves a Terraform file which setups 1 app server and 1 db server and then does its own provisioning depending on how the application and database need to be deployed. It took me about a month to put this all together but I am now secure and sane in the knowledge i can easily setup any website on any cloud provider that Terraform supports (AWS,Openstack,Azure,Google Cloud) and do not have to hesistate about setting up new servers or replacing old ones.

Thanks kzap, this is is great! Terraform is a great tool to provision and deploy apps (and I definitely consider a LAMP stack an app). You’re right that cloud servers are different than traditional hosting. We work hard to ensure even our ephemeral instances are as stable as possible but it’s still smarter to treat your infrastructure as cattle rather than pets.

Hi kzap, this is a really cool tutorial. I work in developer relations on the cloud team at DreamHost and want to thank you for writing this guide. We’re always interested in learning more about our users and sharing their stories. How do you use DreamHost Cloud? We’re also starting a program to remunerate contributions to our knowledge base: Would you be interested in writing a tutorial to use terraform? Please let us know how we can help you.

Hi Calebb sure, do i just submit a PR to the github docs?

We run an ecommerce site and are moving from Linode here due to OpenStack and the pricing. I’m used to Rackspace Cloud but OpenStack makes us able to use the same code anywhere.

Awesome. Yep the github repo is https://github.com/dreamhost/DreamCloud-docs . The articles are written in Restructured Text Format (RST) and are organized in the repo by their categories and sections on the actual knowledge base. We are still developing the program of accepting documentation from users so it’s likely there will be some bumps, but if you write something up and make a PR we can review it and move on from there. If you need any help with that, feel free to ask. Thanks