The DevOps landscape is continuously evolving at an ever-increasing pace. Some of the tools and approaches that I had gotten accustomed to have just gotten better providing me with more options to play with, which is always a good thing.
One of the tools we use in our delivery process is vagrant by Mitchell Hashimoto. This allows us to provide all our developers an isolated environment to deploy and test applications on their local machines repeatedly and consistently.
By default, vagrant runs on virtualbox virtual machines. But, recently vagrant has been extended to run on AWS EC2, as well as other environments. This move has already impacted our tool chain and there are a number of other interesting features like parallel provisioning on AWS on the horizon.
So, to get started, you can get the latest version of vagrant (1.2.2 as of this post) at http://downloads.vagrantup.com/ for your operating system.
Then install the vagrant-aws plugin as follows –
The next step is to setup your local environment with AWS credentials. Many projects would likely commit their Vagrant configuration to some version control repository. However it’s best to reference your local environment for the required keys. To do so, add the following to your local users’ ~/.profile file
Then we need to source the ~/.profile to make the variables available in the current shell session
Every AWS EC2 instance would have an ssh key pair. I keep my ssh private key in ~/.ssh/development.pem
Now that we have our local environment in shape, we need to setup our vagrant configuration file – Vagrantfile. Copy this example Vagrantfile to your project root and modify with your details accordingly –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
Then run the following to launch the instance from your project root –
And there you have it ! You can ssh into the instance with the following –