• This repository has been archived on 11/Feb/2022
  • Stars
    star
    2,607
  • Rank 16,874 (Top 0.4 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 11 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Use Vagrant to manage your EC2 and VPC instances.

Vagrant AWS Provider

![Gitter](https://badges.gitter.im/Join Chat.svg)

[![Gem Version](https://badge.fury.io/rb/vagrant-aws.png)][gem] [![Dependency Status](https://gemnasium.com/mitchellh/vagrant-aws.png)][gemnasium]

This is a Vagrant 1.2+ plugin that adds an AWS provider to Vagrant, allowing Vagrant to control and provision machines in EC2 and VPC.

NOTE: This plugin requires Vagrant 1.2+,

Features

  • Boot EC2 or VPC instances.
  • SSH into the instances.
  • Provision the instances with any built-in Vagrant provisioner.
  • Minimal synced folder support via rsync.
  • Define region-specific configurations so Vagrant can manage machines in multiple regions.
  • Package running instances into new vagrant-aws friendly boxes

Usage

Install using standard Vagrant 1.1+ plugin installation methods. After installing, vagrant up and specify the aws provider. An example is shown below.

$ vagrant plugin install vagrant-aws
...
$ vagrant up --provider=aws
...

Of course prior to doing this, you'll need to obtain an AWS-compatible box file for Vagrant.

Quick Start

After installing the plugin (instructions above), the quickest way to get started is to actually use a dummy AWS box and specify all the details manually within a config.vm.provider block. So first, add the dummy box using any name you want:

$ vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
...

And then make a Vagrantfile that looks like the following, filling in your information where necessary.

Vagrant.configure("2") do |config|
  config.vm.box = "dummy"

  config.vm.provider :aws do |aws, override|
    aws.access_key_id = "YOUR KEY"
    aws.secret_access_key = "YOUR SECRET KEY"
    aws.session_token = "SESSION TOKEN"
    aws.keypair_name = "KEYPAIR NAME"

    aws.ami = "ami-7747d01e"

    override.ssh.username = "ubuntu"
    override.ssh.private_key_path = "PATH TO YOUR PRIVATE KEY"
  end
end

And then run vagrant up --provider=aws.

This will start an Ubuntu 12.04 instance in the us-east-1 region within your account. And assuming your SSH information was filled in properly within your Vagrantfile, SSH and provisioning will work as well.

Note that normally a lot of this boilerplate is encoded within the box file, but the box file used for the quick start, the "dummy" box, has no preconfigured defaults.

If you have issues with SSH connecting, make sure that the instances are being launched with a security group that allows SSH access.

Note: if you don't configure aws.access_key_id or aws_secret_access_key it will attempt to read credentials from environment variables first and then from $HOME/.aws/. You can choose your AWS profile and files location by using aws.aws_profile and aws.aws_dir, however environment variables will always have precedence as defined by the AWS documentation. To use profile vagrantDev from your AWS files:

  # this first line can actually be omitted
  aws.aws_dir = ENV['HOME'] + "/.aws/"
  aws.aws_profile = "vagrantDev"

Box Format

Every provider in Vagrant must introduce a custom box format. This provider introduces aws boxes. You can view an example box in the example_box/ directory. That directory also contains instructions on how to build a box.

The box format is basically just the required metadata.json file along with a Vagrantfile that does default settings for the provider-specific configuration for this provider.

Configuration

This provider exposes quite a few provider-specific configuration options:

  • access_key_id - The access key for accessing AWS
  • ami - The AMI id to boot, such as "ami-12345678"
  • availability_zone - The availability zone within the region to launch the instance. If nil, it will use the default set by Amazon.
  • aws_profile - AWS profile in your config files. Defaults to default.
  • aws_dir - AWS config and credentials location. Defaults to $HOME/.aws/.
  • instance_ready_timeout - The number of seconds to wait for the instance to become "ready" in AWS. Defaults to 120 seconds.
  • instance_check_interval - The number of seconds to wait to check the instance's state
  • instance_package_timeout - The number of seconds to wait for the instance to be burnt into an AMI during packaging. Defaults to 600 seconds.
  • instance_type - The type of instance, such as "m3.medium". The default value of this if not specified is "m3.medium". "m1.small" has been deprecated in "us-east-1" and "m3.medium" is the smallest instance type to support both paravirtualization and hvm AMIs
  • keypair_name - The name of the keypair to use to bootstrap AMIs which support it.
  • monitoring - Set to "true" to enable detailed monitoring.
  • session_token - The session token provided by STS
  • private_ip_address - The private IP address to assign to an instance within a VPC
  • elastic_ip - Can be set to 'true', or to an existing Elastic IP address. If true, allocate a new Elastic IP address to the instance. If set to an existing Elastic IP address, assign the address to the instance.
  • region - The region to start the instance in, such as "us-east-1"
  • secret_access_key - The secret access key for accessing AWS
  • security_groups - An array of security groups for the instance. If this instance will be launched in VPC, this must be a list of security group Name. For a nondefault VPC, you must use security group IDs instead (http://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html).
  • iam_instance_profile_arn - The Amazon resource name (ARN) of the IAM Instance Profile to associate with the instance
  • iam_instance_profile_name - The name of the IAM Instance Profile to associate with the instance
  • subnet_id - The subnet to boot the instance into, for VPC.
  • associate_public_ip - If true, will associate a public IP address to an instance in a VPC.
  • ssh_host_attribute - If :public_ip_address, :dns_name, or :private_ip_address, will use the public IP address, DNS name, or private IP address, respectively, to SSH to the instance. By default Vagrant uses the first of these (in this order) that is known. However, this can lead to connection issues if, e.g., you are assigning a public IP address but your security groups prevent public SSH access and require you to SSH in via the private IP address; specify :private_ip_address in this case.
  • tenancy - When running in a VPC configure the tenancy of the instance. Supports 'default' and 'dedicated'.
  • tags - A hash of tags to set on the machine.
  • package_tags - A hash of tags to set on the ami generated during the package operation.
  • use_iam_profile - If true, will use IAM profiles for credentials.
  • block_device_mapping - Amazon EC2 Block Device Mapping Property
  • elb - The ELB name to attach to the instance.
  • unregister_elb_from_az - Removes the ELB from the AZ on removal of the last instance if true (default). In non default VPC this has to be false.
  • terminate_on_shutdown - Indicates whether an instance stops or terminates when you initiate shutdown from the instance.
  • endpoint - The endpoint URL for connecting to AWS (or an AWS-like service). Only required for non AWS clouds, such as eucalyptus.

These can be set like typical provider-specific configuration:

Vagrant.configure("2") do |config|
  # ... other stuff

  config.vm.provider :aws do |aws|
    aws.access_key_id = "foo"
    aws.secret_access_key = "bar"
  end
end

Note that you do not have to hard code your aws.access_key_id or aws.secret_access_key as they will be retrieved from the enviornment variables AWS_ACCESS_KEY and AWS_SECRET_KEY.

In addition to the above top-level configs, you can use the region_config method to specify region-specific overrides within your Vagrantfile. Note that the top-level region config must always be specified to choose which region you want to actually use, however. This looks like this:

Vagrant.configure("2") do |config|
  # ... other stuff

  config.vm.provider :aws do |aws|
    aws.access_key_id = "foo"
    aws.secret_access_key = "bar"
    aws.region = "us-east-1"

    # Simple region config
    aws.region_config "us-east-1", :ami => "ami-12345678"

    # More comprehensive region config
    aws.region_config "us-west-2" do |region|
      region.ami = "ami-87654321"
      region.keypair_name = "company-west"
    end
  end
end

The region-specific configurations will override the top-level configurations when that region is used. They otherwise inherit the top-level configurations, as you would probably expect.

Networks

Networking features in the form of config.vm.network are not supported with vagrant-aws, currently. If any of these are specified, Vagrant will emit a warning, but will otherwise boot the AWS machine.

Synced Folders

There is minimal support for synced folders. Upon vagrant up, vagrant reload, and vagrant provision, the AWS provider will use rsync (if available) to uni-directionally sync the folder to the remote machine over SSH.

See Vagrant Synced folders: rsync

Other Examples

Tags

To use tags, simply define a hash of key/value for the tags you want to associate to your instance, like:

Vagrant.configure("2") do |config|
  # ... other stuff

  config.vm.provider "aws" do |aws|
    aws.tags = {
	  'Name' => 'Some Name',
	  'Some Key' => 'Some Value'
    }
  end
end

User data

You can specify user data for the instance being booted.

Vagrant.configure("2") do |config|
  # ... other stuff

  config.vm.provider "aws" do |aws|
    # Option 1: a single string
    aws.user_data = "#!/bin/bash\necho 'got user data' > /tmp/user_data.log\necho"

    # Option 2: use a file
    aws.user_data = File.read("user_data.txt")
  end
end

Disk size

Need more space on your instance disk? Increase the disk size.

Vagrant.configure("2") do |config|
  # ... other stuff

  config.vm.provider "aws" do |aws|
    aws.block_device_mapping = [{ 'DeviceName' => '/dev/sda1', 'Ebs.VolumeSize' => 50 }]
  end
end

ELB (Elastic Load Balancers)

You can automatically attach an instance to an ELB during boot and detach on destroy.

Vagrant.configure("2") do |config|
  # ... other stuff

  config.vm.provider "aws" do |aws|
    aws.elb = "production-web"
  end
end

Development

To work on the vagrant-aws plugin, clone this repository out, and use Bundler to get the dependencies:

$ bundle

Once you have the dependencies, verify the unit tests pass with rake:

$ bundle exec rake

If those pass, you're ready to start developing the plugin. You can test the plugin without installing it into your Vagrant environment by just creating a Vagrantfile in the top level of this directory (it is gitignored) and add the following line to your Vagrantfile

Vagrant.require_plugin "vagrant-aws"

Use bundler to execute Vagrant:

$ bundle exec vagrant up --provider=aws

More Repositories

1

mapstructure

Go library for decoding generic map values into native Go structures and vice versa.
Go
7,477
star
2

gox

A dead simple, no frills Go cross compile tool
Go
4,589
star
3

cli

A Go library for implementing command-line interfaces.
Go
1,708
star
4

nixos-config

My NixOS configurations.
Nix
1,663
star
5

gon

Sign, notarize, and package macOS CLI tools and applications written in any language. Available as both a CLI and a Go library.
Go
1,460
star
6

go-ps

Find, list, and inspect processes from Go (golang).
Go
1,430
star
7

go-homedir

Go library for detecting and expanding the user's home directory without cgo.
Go
1,364
star
8

libxev

libxev is a cross-platform, high-performance event loop that provides abstractions for non-blocking IO, timers, events, and more and works on Linux (io_uring or epoll), macOS (kqueue), and Wasm + WASI. Available as both a Zig and C API.
Zig
879
star
9

go-server-timing

Go (golang) library for creating and consuming HTTP Server-Timing headers
Go
858
star
10

hashstructure

Get hash values for arbitrary values in Go (golang).
Go
727
star
11

goamz

Golang Amazon Library
Go
674
star
12

golicense

Scan and analyze OSS dependencies and licenses from compiled Go binaries
Go
666
star
13

ioprogress

Go (golang) package for progress bars around io.Reader/Writers.
Go
503
star
14

go-mruby

Go (golang) bindings to mruby.
Go
468
star
15

advent-2021-sql

Advent of Code 2021 using SQL (PostgreSQL-flavored)
PLpgSQL
435
star
16

panicwrap

panicwrap is a Go library for catching and handling panics in Go applications.
Go
435
star
17

boot2docker-vagrant-box

Packer scripts to build a Vagrant-compatible boot2docker box.
Smarty
424
star
18

copystructure

Go (golang) library for deep copying values in Go.
Go
339
star
19

vagrant-google

Vagrant provider for GCE.
Ruby
332
star
20

go-glint

Component-based UI-framework for command-line tools. Easily create highly dynamic CLI interfaces using shared, easily testable components.
Go
312
star
21

go-vnc

VNC client and server library for Go.
Go
279
star
22

colorstring

Go (golang) library for colorizing strings for terminal output.
Go
277
star
23

reflectwalk

reflectwalk is a Go library for "walking" complex structures, similar to walking a filesystem.
Go
270
star
24

virtualbox

[ABANDONED] Create and modify virtual machines in VirtualBox using pure ruby.
Ruby
244
star
25

vagrant-rackspace

Use Vagrant to manage Rackspace Cloud instances.
Ruby
235
star
26

protoc-gen-go-json

Protobuf compiler plugin to generate Go JSON Marshal/Unmarshal implementations for messages using jsonpb.
Go
221
star
27

pointerstructure

Go library for addressing and reading/writing a specific value within any Go structure using a string syntax.
Go
213
star
28

dotfiles

My personal dotfiles.
Batchfile
176
star
29

protostructure

Encode and decode Go (golang) struct types via protocol buffers.
Go
173
star
30

consulstructure

Decode Consul data into Go (Golang) structures and watch for updates
Go
173
star
31

zig-js

Access the JS host environment from Zig compiled to WebAssembly.
Zig
170
star
32

zig-overlay

Nix flake for the Zig compiler.
Nix
160
star
33

packer-ubuntu-12.04-docker

Packer template that builds images that are Docker-ready on Ubuntu 12.04.
Shell
157
star
34

terraform-provider-multispace

Terraform Provider for cascading runs across multiple workspaces.
Go
147
star
35

multistep

multistep is a Go library for building up complex actions using discrete steps.
Go
145
star
36

zig-libgc

Zig-friendly library for interfacing with libgc (bdwgc) -- the Boehm-Demers-Weiser conservative garbage collector
Zig
141
star
37

go-z3

Go (golang) bindings to the Z3 SMT Solver
Go
139
star
38

libflightplan

A library for reading and writing flight plans in various formats. Available as both a C and Zig library.
Zig
134
star
39

go-sat

SAT solver written in Go (golang).
Go
133
star
40

zig-objc

Objective-C runtime bindings for Zig (Zig calling ObjC).
Zig
131
star
41

go-wordwrap

A Go (golang) library for wrapping words in a string.
Go
107
star
42

vim-misc

My Vim configuration files.
Vim Script
99
star
43

middleware

Generalized middleware implementation for Ruby.
Ruby
94
star
44

go-fs

Filesystem library for Go, implementing FAT filesystems so far.
Go
86
star
45

zig-graph

Directed graph data structure for Zig
Zig
81
star
46

go-grpc-net-conn

Turn any gRPC stream into a Go `net.Conn` implementation.
Go
79
star
47

lightcloud

Library for accessing Plurk's LightCloud distributed key-value store for Ruby
Ruby
75
star
48

zig-libxml2

libxml2 built using Zig build system
Zig
74
star
49

tree-sitter-hcl

A tree-sitter grammar for HCL (HashiCorp Configuration Language), used by projects such as Terraform.
C
67
star
50

go-linereader

Golang package that reads lines from an io.Reader and puts them onto a channel.
Go
66
star
51

veewee-to-packer

A tool for converting Veewee templates into Packer templates.
Ruby
65
star
52

vagrant-rake

A Vagrant plugin to execute `rake` commands from the host in the VM
Ruby
62
star
53

tree-sitter-proto

A tree-sitter grammar for protocol buffer files (proto3).
C
59
star
54

libvirt-rb

[ABANDONED] A ruby client library providing an interface to libvirt via FFI.
Ruby
59
star
55

go-testing-interface

Go (golang) library to expose *testing.T as an interface.
Go
59
star
56

patchstructure

Go library for representing and applying patches to modify existing Go structures
Go
56
star
57

go-finger

Finger protocol library
Go
55
star
58

squire

Go
55
star
59

go-libucl

Bindings to libucl from Go (golang).
Go
54
star
60

go-bnet

Go (golang) client for the Battle.net API
Go
52
star
61

libssh2-ruby

libssh2 bindings for Ruby
Ruby
47
star
62

iochan

A Go library for turning `io.Reader` into channels.
Go
43
star
63

prefixedio

Golang library that demultiplexes line-oriented data from an io.Reader into multiple io.Readers based on a prefix.
Go
42
star
64

tlaplus-radix-tree

TLA+ modules, specifications, and models for Radix trees.
TLA
33
star
65

caststructure

A Go library that provides functions for downcasting types, composing values dynamically, and more.
Go
32
star
66

flask-nix-example

Dockerfile
31
star
67

virtuoso

Dead simple virtual machine management over many hypervisors.
Ruby
30
star
68

hash_ring

Consistent hashing in Ruby. Ported from Amir Sailhefendic's hash_ring python library.
Ruby
28
star
69

terraform-aws-dynamic-keys

Terraform module that dynamically generates a public/private keypair.
HCL
26
star
70

go-spdx

Golang library for listing and looking up licenses using SPDX IDs.
Go
24
star
71

ruburple

A ruby interface to libpurple. Copied for git.
C
20
star
72

iorpc

Golang io interfaces across an RPC connection.
Go
18
star
73

fusion-m1-514-repro

Makefile
17
star
74

omniconfig

Flexible configuration for your Ruby applications and libraries.
Ruby
14
star
75

terraform-aws-fastai

Terraform module to create Fast.ai course instance.
HCL
12
star
76

radar

Easily report errors in your libraries and applications any way you want!
Ruby
12
star
77

zig-libuv

Zig bindings for libuv. Also a build script to build libuv from scratch using only Zig (for easy cross-compilation, integration with Zig, etc.).
Zig
11
star
78

zig-build-macos-sdk

macOS SDK package for Zig build.
C
11
star
79

tiad-demo

Demo for The Incredible Automation Day in Paris.
Shell
10
star
80

waypoint-helm

WIP
Smarty
9
star
81

boto-route53

Route53 API built on top of Boto
Python
8
star
82

fogli

An efficient, simple, and intuitive Facebook Open Graph library
Ruby
8
star
83

minitest-mark

Proof of concept minitest extension to add test marking.
Ruby
7
star
84

vagrant-downloads

The Vagrant downloads website.
Ruby
7
star
85

zig-build-libxml2

The libxml2 library built and packaged for the Zig build system. These are not Zig language bindings to the library.
C
6
star
86

minitest-parallel

Proof of concept to run your minitest tests in parallel.
Ruby
6
star
87

goconf

This is a copy of http://code.google.com/p/goconf/
Go
6
star
88

packer-go-bootcamp

Packer templates for the Go Bootcamp images.
Shell
6
star
89

larubyconf-vagrant-examples

Examples of using Vagrant from LARubyConf
Ruby
6
star
90

xidl

Parses XIDL files into Ruby objects.
Ruby
5
star
91

bintray-download-site

Simple Rack app for creating easy downloads for your Bintray packages.
Ruby
5
star
92

terraform-aws-vpc

Temporary, testing something, ignore this.
HCL
5
star
93

zig-build-xcode-frameworks

Exposing hexops/xcode-frameworks to the Zig package manager to work around some bugs.
Zig
5
star
94

minitest-speed

Proof of concept speed tests using minitest.
Ruby
5
star
95

homebrew-gon

Homebrew Tap for Gon (github.com/mitchellh/gon)
Ruby
4
star
96

osext

Copy of https://bitbucket.org/kardianos/osext
Go
4
star
97

minitest-funcarg

Proof of concept showing funcargs (style of DI) in minitest.
Ruby
4
star
98

go-bootcamp-remotecmds

My solution for the remotecmds problem for the Go Bootcamp I'm helping to instruct.
Go
4
star
99

lifeguard-random

Data source plugin for Lifeguard that generates random numbers.
Shell
4
star
100

lifeguard-graphite

Data source plugin for Lifeguard to query data from Graphite.
Shell
4
star