vagrant-gecko-aws 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.rspec +1 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +96 -0
- data/Gemfile +10 -0
- data/LICENSE +8 -0
- data/README.md +329 -0
- data/Rakefile +22 -0
- data/dummy.box +0 -0
- data/example_box/README.md +13 -0
- data/example_box/metadata.json +3 -0
- data/lib/vagrant-aws/action/connect_aws.rb +48 -0
- data/lib/vagrant-aws/action/elb_deregister_instance.rb +24 -0
- data/lib/vagrant-aws/action/elb_register_instance.rb +24 -0
- data/lib/vagrant-aws/action/is_created.rb +18 -0
- data/lib/vagrant-aws/action/is_stopped.rb +18 -0
- data/lib/vagrant-aws/action/message_already_created.rb +16 -0
- data/lib/vagrant-aws/action/message_not_created.rb +16 -0
- data/lib/vagrant-aws/action/message_will_not_destroy.rb +16 -0
- data/lib/vagrant-aws/action/package_instance.rb +192 -0
- data/lib/vagrant-aws/action/read_ssh_info.rb +53 -0
- data/lib/vagrant-aws/action/read_state.rb +38 -0
- data/lib/vagrant-aws/action/run_instance.rb +314 -0
- data/lib/vagrant-aws/action/start_instance.rb +81 -0
- data/lib/vagrant-aws/action/stop_instance.rb +28 -0
- data/lib/vagrant-aws/action/terminate_instance.rb +51 -0
- data/lib/vagrant-aws/action/timed_provision.rb +21 -0
- data/lib/vagrant-aws/action/wait_for_state.rb +41 -0
- data/lib/vagrant-aws/action/warn_networks.rb +19 -0
- data/lib/vagrant-aws/action.rb +210 -0
- data/lib/vagrant-aws/config.rb +572 -0
- data/lib/vagrant-aws/errors.rb +43 -0
- data/lib/vagrant-aws/plugin.rb +73 -0
- data/lib/vagrant-aws/provider.rb +50 -0
- data/lib/vagrant-aws/util/elb.rb +58 -0
- data/lib/vagrant-aws/util/timer.rb +17 -0
- data/lib/vagrant-aws/version.rb +5 -0
- data/lib/vagrant-aws.rb +18 -0
- data/locales/en.yml +159 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/vagrant-aws/config_spec.rb +374 -0
- data/templates/metadata.json.erb +3 -0
- data/templates/vagrant-aws_package_Vagrantfile.erb +5 -0
- data/vagrant-aws.gemspec +58 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 42ad902c2b00e88f8d90897a5173c3bcf4b234ea990bcb459840d4d274ff31fc
|
4
|
+
data.tar.gz: 12d69fe7e86840e1dd9c7eb1fa272979341d6e15360dc58238aa1256fa6709d1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ba1d5786f3a4a056d9013037c452aaa0cf4fc819ea6236031fe4f718274348f27099cdfc97092093f62d12d3d1fe385ffdce474d4830cbed38186c85fe26a76d
|
7
|
+
data.tar.gz: 55286ce77380d833c93ad3c2a2ee12b50ad9a0520eed48f8e66345d874b91cf6419aac1015afe1cabf9ab2da8c13e010d30c01b0932575c0c9a8341660be6ba3
|
data/.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# OS-specific
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
# editors
|
5
|
+
*.swp
|
6
|
+
|
7
|
+
# Bundler/Rubygems
|
8
|
+
*.gem
|
9
|
+
.bundle
|
10
|
+
pkg/*
|
11
|
+
tags
|
12
|
+
Gemfile.lock
|
13
|
+
|
14
|
+
# Vagrant
|
15
|
+
.vagrant
|
16
|
+
Vagrantfile
|
17
|
+
!example_box/Vagrantfile
|
18
|
+
|
19
|
+
# RVM files for gemset/ruby setting
|
20
|
+
.ruby-*
|
21
|
+
.rvmrc
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--format doc --order random --color --fail-fast
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# 0.6.1
|
2
|
+
|
3
|
+
* Added configurable instance state check interval
|
4
|
+
|
5
|
+
# 0.6.0 (December 13, 2014)
|
6
|
+
|
7
|
+
* Support static Elastic IP addresses.
|
8
|
+
* Support for creating AMIs with the `vagrant package`
|
9
|
+
|
10
|
+
# 0.5.0 (June 22, 2014)
|
11
|
+
|
12
|
+
* Support for associating public IPs for VMs inside of VPCs (GH
|
13
|
+
[#219](https://github.com/mitchellh/vagrant-aws/pull/219), GH
|
14
|
+
[#205](https://github.com/mitchellh/vagrant-aws/issues/205))
|
15
|
+
* Bug-fix for per region configs with `associate_public_ip` (GH
|
16
|
+
[#237](https://github.com/mitchellh/vagrant-aws/pull/237))
|
17
|
+
* rsyncing folders uses `--delete` flag to better emulate "real shared folders
|
18
|
+
(GH [#194](https://github.com/mitchellh/vagrant-aws/pull/194))
|
19
|
+
* fog gem version bumped to 1.22 (GH [#253](https://github.com/mitchellh/vagrant-aws/pull/253))
|
20
|
+
* Simple ELB support (GH [#88](https://github.com/mitchellh/vagrant-aws/pull/88),
|
21
|
+
GH [#238](https://github.com/mitchellh/vagrant-aws/pull/238))
|
22
|
+
|
23
|
+
# 0.4.1 (December 17, 2013)
|
24
|
+
|
25
|
+
* Update fog.io to 1.18.0
|
26
|
+
* Fix sync folder user permissions (GH #175)
|
27
|
+
* Fix vagrant < 1.3.0 provisioner compatibility (GH #173)
|
28
|
+
* Add vagrant 1.4.0 multiple SSH key support (GH #172)
|
29
|
+
* Fix EIP deallocation bug (GH #164)
|
30
|
+
* Add (per shared folder) rsync exclude flag (GH #156)
|
31
|
+
|
32
|
+
# 0.4.0 (October 11, 2013)
|
33
|
+
|
34
|
+
* Handle EIP allocation error (GH #134)
|
35
|
+
* Implement halt and reload (GH #31)
|
36
|
+
* rsync ignores Vagrantfile
|
37
|
+
* warn if none of the security groups allows incoming SSH
|
38
|
+
* bump fog.io to 1.15.0
|
39
|
+
* Fix rsync on windows (GH #77)
|
40
|
+
* Add `ssh_host_attribute` config (GH #143)
|
41
|
+
|
42
|
+
# 0.3.0 (September 2, 2013)
|
43
|
+
|
44
|
+
* Parallelize multi-machine up on Vagrant 1.2+
|
45
|
+
* Show proper configuration errors if an invalid configuration key
|
46
|
+
is used.
|
47
|
+
* Request confirmation on `vagrant destroy`, like normal VirtualBox + Vagrant.
|
48
|
+
* If user data is configured, output is shown on "vagrant up" that
|
49
|
+
it is being set.
|
50
|
+
* Add EIP support (GH #65)
|
51
|
+
* Add block device mapping support (GH #93)
|
52
|
+
* README improvements (GH #120)
|
53
|
+
* Fix missing locale message (GH #73)
|
54
|
+
* SyncFolders creates hostpath if it doesn't exist and `:create` option is set (GH #17)
|
55
|
+
* Add IAM Instance Profile support (GH #68)
|
56
|
+
* Add shutdown behavior support (GH #125,#131)
|
57
|
+
|
58
|
+
# 0.2.2 (April 18, 2013)
|
59
|
+
|
60
|
+
* Fix crashing bug with incorrect provisioner arguments.
|
61
|
+
|
62
|
+
# 0.2.1 (April 16, 2013)
|
63
|
+
|
64
|
+
* Got rid of extranneous references to old SSH settings.
|
65
|
+
|
66
|
+
# 0.2.0 (April 16, 2013)
|
67
|
+
|
68
|
+
* Add support for `vagrant ssh -c` [GH-42]
|
69
|
+
* Ability to specify a timeout for waiting for instances to become ready. [GH-44]
|
70
|
+
* Better error message if instance didn't become ready in time.
|
71
|
+
* Connection can now be done using IAM profiles. [GH-41]
|
72
|
+
|
73
|
+
# 0.1.3 (April 9, 2013)
|
74
|
+
|
75
|
+
* The `AWS_ACCESS_KEY` and `AWS_SECRET_KEY` will be used if available
|
76
|
+
and no specific keys are set in the Vagrantfile. [GH-33]
|
77
|
+
* Fix issues with SSH on VPCs, the correct IP is used. [GH-30]
|
78
|
+
* Exclude the ".vagrant" directory from rsync.
|
79
|
+
* Implement `:disabled` flag support for shared folders. [GH-29]
|
80
|
+
* `aws.user_data` to specify user data on the instance. [GH-26]
|
81
|
+
|
82
|
+
# 0.1.2 (March 22, 2013)
|
83
|
+
|
84
|
+
* Choose the proper region when connecting to AWS. [GH-9]
|
85
|
+
* Configurable SSH port. [GH-13]
|
86
|
+
* Support other AWS-compatible API endpoints with `config.endpoint`
|
87
|
+
and `config.version`. [GH-6]
|
88
|
+
* Disable strict host key checking on rsync so known hosts aren't an issue. [GH-7]
|
89
|
+
|
90
|
+
# 0.1.1 (March 18, 2013)
|
91
|
+
|
92
|
+
* Up fog dependency for Vagrant 1.1.1
|
93
|
+
|
94
|
+
# 0.1.0 (March 14, 2013)
|
95
|
+
|
96
|
+
* Initial release.
|
data/Gemfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
group :development do
|
6
|
+
# We depend on Vagrant for development, but we don't add it as a
|
7
|
+
# gem dependency because we expect to be installed within the
|
8
|
+
# Vagrant environment itself using `vagrant plugin`.
|
9
|
+
gem "vagrant", :git => "https://github.com/mitchellh/vagrant.git"
|
10
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
Copyright (c) 2014 Mitchell Hashimoto
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
7
|
+
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,329 @@
|
|
1
|
+
# Vagrant AWS Provider
|
2
|
+
|
3
|
+
> **Warning**
|
4
|
+
>
|
5
|
+
> This is a fork of the original [plugin](https://github.com/mitchellh/vagrant-aws)
|
6
|
+
> with updated dependencies so that it works with the latest versions of
|
7
|
+
> vagrant.
|
8
|
+
>
|
9
|
+
> The fork will be maintained to the extent that it is kept working, but will
|
10
|
+
> not be providing any new functionality or support, it is shared and published
|
11
|
+
> only to assist people wanting to continue using the plugin themselves.
|
12
|
+
|
13
|
+
[![Gem Version](https://badge.fury.io/rb/vagrant-gecko-aws.png)](https://rubygems.org/gems/vagrant-gecko-aws)
|
14
|
+
|
15
|
+
This is a [Vagrant](http://www.vagrantup.com) 2.3.7+ plugin that adds an [AWS](http://aws.amazon.com)
|
16
|
+
provider to Vagrant, allowing Vagrant to control and provision machines in
|
17
|
+
EC2 and VPC.
|
18
|
+
|
19
|
+
**NOTE:** This plugin requires Vagrant 2.3.7+,
|
20
|
+
|
21
|
+
## Features
|
22
|
+
|
23
|
+
* Boot EC2 or VPC instances.
|
24
|
+
* SSH into the instances.
|
25
|
+
* Provision the instances with any built-in Vagrant provisioner.
|
26
|
+
* Minimal synced folder support via `rsync`.
|
27
|
+
* Define region-specific configurations so Vagrant can manage machines
|
28
|
+
in multiple regions.
|
29
|
+
* Package running instances into new vagrant-aws friendly boxes
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
Install using standard Vagrant 1.1+ plugin installation methods. After
|
34
|
+
installing, `vagrant up` and specify the `aws` provider. An example is
|
35
|
+
shown below.
|
36
|
+
|
37
|
+
```
|
38
|
+
$ vagrant plugin install vagrant-gecko-aws --entry-point vagrant-aws
|
39
|
+
...
|
40
|
+
$ vagrant up --provider=aws
|
41
|
+
...
|
42
|
+
```
|
43
|
+
|
44
|
+
Of course prior to doing this, you'll need to obtain an AWS-compatible
|
45
|
+
box file for Vagrant.
|
46
|
+
|
47
|
+
## Quick Start
|
48
|
+
|
49
|
+
After installing the plugin (instructions above), the quickest way to get
|
50
|
+
started is to actually use a dummy AWS box and specify all the details
|
51
|
+
manually within a `config.vm.provider` block. So first, add the dummy
|
52
|
+
box using any name you want:
|
53
|
+
|
54
|
+
```
|
55
|
+
$ vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
|
56
|
+
...
|
57
|
+
```
|
58
|
+
|
59
|
+
And then make a Vagrantfile that looks like the following, filling in
|
60
|
+
your information where necessary.
|
61
|
+
|
62
|
+
```
|
63
|
+
Vagrant.configure("2") do |config|
|
64
|
+
config.vm.box = "dummy"
|
65
|
+
|
66
|
+
config.vm.provider :aws do |aws, override|
|
67
|
+
aws.access_key_id = "YOUR KEY"
|
68
|
+
aws.secret_access_key = "YOUR SECRET KEY"
|
69
|
+
aws.session_token = "SESSION TOKEN"
|
70
|
+
aws.keypair_name = "KEYPAIR NAME"
|
71
|
+
|
72
|
+
aws.ami = "ami-7747d01e"
|
73
|
+
|
74
|
+
override.ssh.username = "ubuntu"
|
75
|
+
override.ssh.private_key_path = "PATH TO YOUR PRIVATE KEY"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
```
|
79
|
+
|
80
|
+
And then run `vagrant up --provider=aws`.
|
81
|
+
|
82
|
+
This will start an Ubuntu 12.04 instance in the us-east-1 region within
|
83
|
+
your account. And assuming your SSH information was filled in properly
|
84
|
+
within your Vagrantfile, SSH and provisioning will work as well.
|
85
|
+
|
86
|
+
Note that normally a lot of this boilerplate is encoded within the box
|
87
|
+
file, but the box file used for the quick start, the "dummy" box, has
|
88
|
+
no preconfigured defaults.
|
89
|
+
|
90
|
+
If you have issues with SSH connecting, make sure that the instances
|
91
|
+
are being launched with a security group that allows SSH access.
|
92
|
+
|
93
|
+
Note: if you don't configure `aws.access_key_id` or `aws_secret_access_key`
|
94
|
+
it will attempt to read credentials from environment variables first and then
|
95
|
+
from `$HOME/.aws/`. You can choose your AWS profile and files location by using
|
96
|
+
`aws.aws_profile` and `aws.aws_dir`, however environment variables will always
|
97
|
+
have precedence as defined by the [AWS documentation](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html).
|
98
|
+
To use profile `vagrantDev` from your AWS files:
|
99
|
+
```ruby
|
100
|
+
# this first line can actually be omitted
|
101
|
+
aws.aws_dir = ENV['HOME'] + "/.aws/"
|
102
|
+
aws.aws_profile = "vagrantDev"
|
103
|
+
```
|
104
|
+
|
105
|
+
|
106
|
+
## Box Format
|
107
|
+
|
108
|
+
Every provider in Vagrant must introduce a custom box format. This
|
109
|
+
provider introduces `aws` boxes. You can view an example box in
|
110
|
+
the [example_box/ directory](https://github.com/mitchellh/vagrant-aws/tree/master/example_box).
|
111
|
+
That directory also contains instructions on how to build a box.
|
112
|
+
|
113
|
+
The box format is basically just the required `metadata.json` file
|
114
|
+
along with a `Vagrantfile` that does default settings for the
|
115
|
+
provider-specific configuration for this provider.
|
116
|
+
|
117
|
+
## Configuration
|
118
|
+
|
119
|
+
This provider exposes quite a few provider-specific configuration options:
|
120
|
+
|
121
|
+
* `access_key_id` - The access key for accessing AWS
|
122
|
+
* `ami` - The AMI id to boot, such as "ami-12345678"
|
123
|
+
* `availability_zone` - The availability zone within the region to launch
|
124
|
+
the instance. If nil, it will use the default set by Amazon.
|
125
|
+
* `aws_profile` - AWS profile in your config files. Defaults to *default*.
|
126
|
+
* `aws_dir` - AWS config and credentials location. Defaults to *$HOME/.aws/*.
|
127
|
+
* `instance_ready_timeout` - The number of seconds to wait for the instance
|
128
|
+
to become "ready" in AWS. Defaults to 120 seconds.
|
129
|
+
* `instance_check_interval` - The number of seconds to wait to check the instance's
|
130
|
+
state
|
131
|
+
* `instance_package_timeout` - The number of seconds to wait for the instance
|
132
|
+
to be burnt into an AMI during packaging. Defaults to 600 seconds.
|
133
|
+
* `instance_type` - The type of instance, such as "m3.medium". The default
|
134
|
+
value of this if not specified is "m3.medium". "m1.small" has been
|
135
|
+
deprecated in "us-east-1" and "m3.medium" is the smallest instance
|
136
|
+
type to support both paravirtualization and hvm AMIs
|
137
|
+
* `keypair_name` - The name of the keypair to use to bootstrap AMIs
|
138
|
+
which support it.
|
139
|
+
* `monitoring` - Set to "true" to enable detailed monitoring.
|
140
|
+
* `session_token` - The session token provided by STS
|
141
|
+
* `private_ip_address` - The private IP address to assign to an instance
|
142
|
+
within a [VPC](http://aws.amazon.com/vpc/)
|
143
|
+
* `elastic_ip` - Can be set to 'true', or to an existing Elastic IP address.
|
144
|
+
If true, allocate a new Elastic IP address to the instance. If set
|
145
|
+
to an existing Elastic IP address, assign the address to the instance.
|
146
|
+
* `region` - The region to start the instance in, such as "us-east-1"
|
147
|
+
* `secret_access_key` - The secret access key for accessing AWS
|
148
|
+
* `security_groups` - An array of security groups for the instance. If this
|
149
|
+
instance will be launched in VPC, this must be a list of security group
|
150
|
+
Name. For a nondefault VPC, you must use security group IDs instead (http://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html).
|
151
|
+
* `iam_instance_profile_arn` - The Amazon resource name (ARN) of the IAM Instance
|
152
|
+
Profile to associate with the instance
|
153
|
+
* `iam_instance_profile_name` - The name of the IAM Instance Profile to associate
|
154
|
+
with the instance
|
155
|
+
* `subnet_id` - The subnet to boot the instance into, for VPC.
|
156
|
+
* `associate_public_ip` - If true, will associate a public IP address to an instance in a VPC.
|
157
|
+
* `ssh_host_attribute` - If `:public_ip_address`, `:dns_name`, or
|
158
|
+
`:private_ip_address`, will use the public IP address, DNS name, or private
|
159
|
+
IP address, respectively, to SSH to the instance. By default Vagrant uses the
|
160
|
+
first of these (in this order) that is known. However, this can lead to
|
161
|
+
connection issues if, e.g., you are assigning a public IP address but your
|
162
|
+
security groups prevent public SSH access and require you to SSH in via the
|
163
|
+
private IP address; specify `:private_ip_address` in this case.
|
164
|
+
* `tenancy` - When running in a VPC configure the tenancy of the instance. Supports 'default' and 'dedicated'.
|
165
|
+
* `tags` - A hash of tags to set on the machine.
|
166
|
+
* `package_tags` - A hash of tags to set on the ami generated during the package operation.
|
167
|
+
* `use_iam_profile` - If true, will use [IAM profiles](http://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html)
|
168
|
+
for credentials.
|
169
|
+
* `block_device_mapping` - Amazon EC2 Block Device Mapping Property
|
170
|
+
* `elb` - The ELB name to attach to the instance.
|
171
|
+
* `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.
|
172
|
+
* `terminate_on_shutdown` - Indicates whether an instance stops or terminates
|
173
|
+
when you initiate shutdown from the instance.
|
174
|
+
* `endpoint` - The endpoint URL for connecting to AWS (or an AWS-like service). Only required for non AWS clouds, such as [eucalyptus](https://github.com/eucalyptus/eucalyptus/wiki).
|
175
|
+
|
176
|
+
These can be set like typical provider-specific configuration:
|
177
|
+
|
178
|
+
```ruby
|
179
|
+
Vagrant.configure("2") do |config|
|
180
|
+
# ... other stuff
|
181
|
+
|
182
|
+
config.vm.provider :aws do |aws|
|
183
|
+
aws.access_key_id = "foo"
|
184
|
+
aws.secret_access_key = "bar"
|
185
|
+
end
|
186
|
+
end
|
187
|
+
```
|
188
|
+
|
189
|
+
Note that you do not have to hard code your `aws.access_key_id` or `aws.secret_access_key`
|
190
|
+
as they will be retrieved from the enviornment variables `AWS_ACCESS_KEY` and `AWS_SECRET_KEY`.
|
191
|
+
|
192
|
+
In addition to the above top-level configs, you can use the `region_config`
|
193
|
+
method to specify region-specific overrides within your Vagrantfile. Note
|
194
|
+
that the top-level `region` config must always be specified to choose which
|
195
|
+
region you want to actually use, however. This looks like this:
|
196
|
+
|
197
|
+
```ruby
|
198
|
+
Vagrant.configure("2") do |config|
|
199
|
+
# ... other stuff
|
200
|
+
|
201
|
+
config.vm.provider :aws do |aws|
|
202
|
+
aws.access_key_id = "foo"
|
203
|
+
aws.secret_access_key = "bar"
|
204
|
+
aws.region = "us-east-1"
|
205
|
+
|
206
|
+
# Simple region config
|
207
|
+
aws.region_config "us-east-1", :ami => "ami-12345678"
|
208
|
+
|
209
|
+
# More comprehensive region config
|
210
|
+
aws.region_config "us-west-2" do |region|
|
211
|
+
region.ami = "ami-87654321"
|
212
|
+
region.keypair_name = "company-west"
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
```
|
217
|
+
|
218
|
+
The region-specific configurations will override the top-level
|
219
|
+
configurations when that region is used. They otherwise inherit
|
220
|
+
the top-level configurations, as you would probably expect.
|
221
|
+
|
222
|
+
## Networks
|
223
|
+
|
224
|
+
Networking features in the form of `config.vm.network` are not
|
225
|
+
supported with `vagrant-aws`, currently. If any of these are
|
226
|
+
specified, Vagrant will emit a warning, but will otherwise boot
|
227
|
+
the AWS machine.
|
228
|
+
|
229
|
+
## Synced Folders
|
230
|
+
|
231
|
+
There is minimal support for synced folders. Upon `vagrant up`,
|
232
|
+
`vagrant reload`, and `vagrant provision`, the AWS provider will use
|
233
|
+
`rsync` (if available) to uni-directionally sync the folder to
|
234
|
+
the remote machine over SSH.
|
235
|
+
|
236
|
+
See [Vagrant Synced folders: rsync](https://docs.vagrantup.com/v2/synced-folders/rsync.html)
|
237
|
+
|
238
|
+
|
239
|
+
## Other Examples
|
240
|
+
|
241
|
+
### Tags
|
242
|
+
|
243
|
+
To use tags, simply define a hash of key/value for the tags you want to associate to your instance, like:
|
244
|
+
|
245
|
+
```ruby
|
246
|
+
Vagrant.configure("2") do |config|
|
247
|
+
# ... other stuff
|
248
|
+
|
249
|
+
config.vm.provider "aws" do |aws|
|
250
|
+
aws.tags = {
|
251
|
+
'Name' => 'Some Name',
|
252
|
+
'Some Key' => 'Some Value'
|
253
|
+
}
|
254
|
+
end
|
255
|
+
end
|
256
|
+
```
|
257
|
+
|
258
|
+
### User data
|
259
|
+
|
260
|
+
You can specify user data for the instance being booted.
|
261
|
+
|
262
|
+
```ruby
|
263
|
+
Vagrant.configure("2") do |config|
|
264
|
+
# ... other stuff
|
265
|
+
|
266
|
+
config.vm.provider "aws" do |aws|
|
267
|
+
# Option 1: a single string
|
268
|
+
aws.user_data = "#!/bin/bash\necho 'got user data' > /tmp/user_data.log\necho"
|
269
|
+
|
270
|
+
# Option 2: use a file
|
271
|
+
aws.user_data = File.read("user_data.txt")
|
272
|
+
end
|
273
|
+
end
|
274
|
+
```
|
275
|
+
|
276
|
+
### Disk size
|
277
|
+
|
278
|
+
Need more space on your instance disk? Increase the disk size.
|
279
|
+
|
280
|
+
```ruby
|
281
|
+
Vagrant.configure("2") do |config|
|
282
|
+
# ... other stuff
|
283
|
+
|
284
|
+
config.vm.provider "aws" do |aws|
|
285
|
+
aws.block_device_mapping = [{ 'DeviceName' => '/dev/sda1', 'Ebs.VolumeSize' => 50 }]
|
286
|
+
end
|
287
|
+
end
|
288
|
+
```
|
289
|
+
|
290
|
+
### ELB (Elastic Load Balancers)
|
291
|
+
|
292
|
+
You can automatically attach an instance to an ELB during boot and detach on destroy.
|
293
|
+
|
294
|
+
```ruby
|
295
|
+
Vagrant.configure("2") do |config|
|
296
|
+
# ... other stuff
|
297
|
+
|
298
|
+
config.vm.provider "aws" do |aws|
|
299
|
+
aws.elb = "production-web"
|
300
|
+
end
|
301
|
+
end
|
302
|
+
```
|
303
|
+
|
304
|
+
## Development
|
305
|
+
|
306
|
+
To work on the `vagrant-aws` plugin, clone this repository out, and use
|
307
|
+
[Bundler](http://gembundler.com) to get the dependencies:
|
308
|
+
|
309
|
+
```
|
310
|
+
$ bundle
|
311
|
+
```
|
312
|
+
|
313
|
+
Once you have the dependencies, verify the unit tests pass with `rake`:
|
314
|
+
|
315
|
+
```
|
316
|
+
$ bundle exec rake
|
317
|
+
```
|
318
|
+
|
319
|
+
If those pass, you're ready to start developing the plugin. You can test
|
320
|
+
the plugin without installing it into your Vagrant environment by just
|
321
|
+
creating a `Vagrantfile` in the top level of this directory (it is gitignored)
|
322
|
+
and add the following line to your `Vagrantfile`
|
323
|
+
```ruby
|
324
|
+
Vagrant.require_plugin "vagrant-aws"
|
325
|
+
```
|
326
|
+
Use bundler to execute Vagrant:
|
327
|
+
```
|
328
|
+
$ bundle exec vagrant up --provider=aws
|
329
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
# Immediately sync all stdout so that tools like buildbot can
|
6
|
+
# immediately load in the output.
|
7
|
+
$stdout.sync = true
|
8
|
+
$stderr.sync = true
|
9
|
+
|
10
|
+
# Change to the directory of this file.
|
11
|
+
Dir.chdir(File.expand_path("../", __FILE__))
|
12
|
+
|
13
|
+
# This installs the tasks that help with gem creation and
|
14
|
+
# publishing.
|
15
|
+
Bundler::GemHelper.install_tasks
|
16
|
+
|
17
|
+
# Install the `spec` task so that we can run tests.
|
18
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
19
|
+
t.rspec_opts = "--order defined"
|
20
|
+
end
|
21
|
+
# Default task is to run the unit tests
|
22
|
+
task :default => :spec
|
data/dummy.box
ADDED
Binary file
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Vagrant AWS Example Box
|
2
|
+
|
3
|
+
Vagrant providers each require a custom provider-specific box format.
|
4
|
+
This folder shows the example contents of a box for the `aws` provider.
|
5
|
+
To turn this into a box:
|
6
|
+
|
7
|
+
```
|
8
|
+
$ tar cvzf aws.box ./metadata.json ./Vagrantfile
|
9
|
+
```
|
10
|
+
|
11
|
+
This box works by using Vagrant's built-in Vagrantfile merging to setup
|
12
|
+
defaults for AWS. These defaults can easily be overwritten by higher-level
|
13
|
+
Vagrantfiles (such as project root Vagrantfiles).
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "fog/aws"
|
2
|
+
require "log4r"
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module AWS
|
6
|
+
module Action
|
7
|
+
# This action connects to AWS, verifies credentials work, and
|
8
|
+
# puts the AWS connection object into the `:aws_compute` key
|
9
|
+
# in the environment.
|
10
|
+
class ConnectAWS
|
11
|
+
def initialize(app, env)
|
12
|
+
@app = app
|
13
|
+
@logger = Log4r::Logger.new("vagrant_aws::action::connect_aws")
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(env)
|
17
|
+
# Get the region we're going to booting up in
|
18
|
+
region = env[:machine].provider_config.region
|
19
|
+
|
20
|
+
# Get the configs
|
21
|
+
region_config = env[:machine].provider_config.get_region_config(region)
|
22
|
+
|
23
|
+
# Build the fog config
|
24
|
+
fog_config = {
|
25
|
+
:provider => 'AWS',
|
26
|
+
:region => region
|
27
|
+
}
|
28
|
+
if region_config.use_iam_profile
|
29
|
+
fog_config[:use_iam_profile] = true
|
30
|
+
else
|
31
|
+
fog_config[:aws_access_key_id] = region_config.access_key_id
|
32
|
+
fog_config[:aws_secret_access_key] = region_config.secret_access_key
|
33
|
+
fog_config[:aws_session_token] = region_config.session_token
|
34
|
+
end
|
35
|
+
|
36
|
+
fog_config[:endpoint] = region_config.endpoint if region_config.endpoint
|
37
|
+
fog_config[:version] = region_config.version if region_config.version
|
38
|
+
|
39
|
+
@logger.info("Connecting to AWS...")
|
40
|
+
env[:aws_compute] = Fog::Compute.new(fog_config)
|
41
|
+
env[:aws_elb] = Fog::AWS::ELB.new(fog_config.except(:provider, :endpoint))
|
42
|
+
|
43
|
+
@app.call(env)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'vagrant-aws/util/elb'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module AWS
|
5
|
+
module Action
|
6
|
+
# This registers instance in ELB
|
7
|
+
class ElbDeregisterInstance
|
8
|
+
include ElasticLoadBalancer
|
9
|
+
|
10
|
+
def initialize(app, env)
|
11
|
+
@app = app
|
12
|
+
@logger = Log4r::Logger.new("vagrant_aws::action::elb_deregister_instance")
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(env)
|
16
|
+
if elb_name = env[:machine].provider_config.elb
|
17
|
+
deregister_instance env, elb_name, env[:machine].id
|
18
|
+
end
|
19
|
+
@app.call(env)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'vagrant-aws/util/elb'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module AWS
|
5
|
+
module Action
|
6
|
+
# This registers instance in ELB
|
7
|
+
class ElbRegisterInstance
|
8
|
+
include ElasticLoadBalancer
|
9
|
+
|
10
|
+
def initialize(app, env)
|
11
|
+
@app = app
|
12
|
+
@logger = Log4r::Logger.new("vagrant_aws::action::elb_register_instance")
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(env)
|
16
|
+
@app.call(env)
|
17
|
+
if elb_name = env[:machine].provider_config.elb
|
18
|
+
register_instance env, elb_name, env[:machine].id
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module AWS
|
3
|
+
module Action
|
4
|
+
# This can be used with "Call" built-in to check if the machine
|
5
|
+
# is created and branch in the middleware.
|
6
|
+
class IsCreated
|
7
|
+
def initialize(app, env)
|
8
|
+
@app = app
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
env[:result] = env[:machine].state.id != :not_created
|
13
|
+
@app.call(env)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module AWS
|
3
|
+
module Action
|
4
|
+
# This can be used with "Call" built-in to check if the machine
|
5
|
+
# is stopped and branch in the middleware.
|
6
|
+
class IsStopped
|
7
|
+
def initialize(app, env)
|
8
|
+
@app = app
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
env[:result] = env[:machine].state.id == :stopped
|
13
|
+
@app.call(env)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module AWS
|
3
|
+
module Action
|
4
|
+
class MessageAlreadyCreated
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
env[:ui].info(I18n.t("vagrant_aws.already_status", :status => "created"))
|
11
|
+
@app.call(env)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|