This repository has been archived by the owner. It is now read-only.
automated aws server creation with vagrant-aws
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
conf
scripts
www
.gitignore
README.md
Vagrantfile

README.md

deploy-aws

A Vagrantfile and associated scripts for easy AWS deployment.

More information here http://trengrj.net/2016/06/18/deploy-aws.html.

Initial AWS Preliminaries

I'm assuming you already have an AWS Account and also have an access key / secret key pair downloaded from AWS with at least permission to create EC2 instances.

The first step is to install the AWS CLI. This allows you to interact with AWS through the command line. I'm using pacman here for example but these packages are pretty easy to install on any machine.

sudo pacman -S aws-cli

Configure aws-cli with your keys and region:

aws configure

Test it out:

aws ec2 describe-instances

You should see a list of the AWS instances you already have running.

Vagrant

Next make sure you have vagrant and vagrant-aws on your system and install the dummy box.

sudo pacman -S vagrant
vagrant plugin install vagrant-aws
vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box

The dummy box is an empty vagrant box as we will be using an AWS ami (in this case Ubuntu 14.04 LTS) as our base image.

Deployment

Download my sample git repo:

git clone https://github.com/trengrj/deploy-aws && cd deploy-aws

This repository consists of a Vagrantfile which specifies how the server is creates, a www directory which is copied as the webroot to the new server, and a set of scripts for managing aws environment variables, keypairs, and security groups.

The scripts will read your current credentials from the same directory AWS CLI uses.

Create a new security group (note this creates a security group called web-ssh which allows inbound HTTP, HTTPS, and SSH.

./scripts/create-security-group.sh

Create a new keypair.

./scripts/create-keypair.sh

And Deploy!

vagrant up --provider=aws

You can view ip of the server as follows.

./scripts/get-ip.sh