|
|
||
|---|---|---|
| .. | ||
| instances.yml | ||
| README.md | ||
| Vagrantfile | ||
Using Vagrant with AWS (Single Instance)
These files were created to allow users to use Vagrant (http://www.vagrantup.com) with AWS, where the VMs managed by Vagrant are actually instances running on AWS. Using these files, Vagrant can only operate against a single instance at a time. This configuration was tested using Vagrant 1.8.1, version 0.7.0 of the vagrant-aws plugin, and AWS.
Contents
-
instances.yml: This YAML file contains the instance-specific configuration information. Six values are expected in this file:
instance_type(the instance type, such as "m3.medium"),region,ami,user,security_groups, andkeypair_name. -
README.md: The file you're currently reading.
-
Vagrantfile: This file is used by Vagrant to spin up the AWS instance. There are two changes that must be made to this file in order for it to function properly: you must specify the correct path to your SSH private key (the private key for the keypair specified in
instances.yml), and you must supply the correct name to the dummy box installed for use with AWS.
Instructions
These instructions assume that you have an AWS account, that you know your AWS access key ID and secret access key, and that you have a valid SSH keypair configured in your AWS account.
-
Vagrant requires that a "dummy box" be installed for use with AWS. Run this command to install the dummy box:
vagrant box add <box-name> https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box -
Install the Vagrant AWS provider by running
vagrant plugin install vagrant-aws. -
Place the files from the
vagrant-awsdirectory of this GitHub repository into a directory on your local system. You can clone the entire "learning-tools" repository (usinggit clone), download a ZIP file of the entire "learning-tools" repository, or just download the specific files from the thevagrant-awsfolder. -
Edit
instances.ymlto supply the correct information to be used by Vagrant when launching an instance on AWS. You'll need to specify the instance type, region, AMI ID, default SSH user for the AMI, a list of security groups (by name, not by security group ID), and the keypair name. -
In a terminal window, set the
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYenvironment variables to your AWS access key ID and AWS secret access key, respectively. -
In the directory where you placed the files from this GitHub repository, run
vagrant upto have Vagrant authenticate to AWS and launch the desired instance for you. Once the instance is created, you can usevagrant sshto connect to the instance, andvagrant destroywill terminate (destroy) the AWS instance for you. (You can follow all these actions in the AWS Management Console, if you so desire.)
Enjoy!
Additional Notes
This environment will only create a single instance on AWS using Vagrant. An environment for spinning up multiple instances is planned for the near future.