tnargav-aws 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitsetup.yml +2 -2
- data/CHANGELOG.md +16 -0
- data/Gemfile +1 -1
- data/README.md +46 -2
- data/lib/vagrant-aws/action.rb +11 -3
- data/lib/vagrant-aws/action/connect_aws.rb +1 -1
- data/lib/vagrant-aws/action/message_will_not_destroy.rb +16 -0
- data/lib/vagrant-aws/action/read_ssh_info.rb +1 -1
- data/lib/vagrant-aws/action/run_instance.rb +70 -13
- data/lib/vagrant-aws/action/sync_folders.rb +11 -0
- data/lib/vagrant-aws/action/terminate_instance.rb +21 -0
- data/lib/vagrant-aws/config.rb +62 -16
- data/lib/vagrant-aws/errors.rb +8 -0
- data/lib/vagrant-aws/plugin.rb +1 -1
- data/lib/vagrant-aws/version.rb +1 -1
- data/locales/en.yml +22 -1
- data/spec/vagrant-aws/config_spec.rb +13 -3
- metadata +90 -83
data/.gitsetup.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
---
|
2
2
|
remotes:
|
3
3
|
vendor: https://github.com/mitchellh/vagrant-aws
|
4
|
-
primary: git@github.com:destructuring/
|
5
|
-
secondary: git@bitbucket.org:destructuring/
|
4
|
+
primary: git@github.com:destructuring/tnargav-aws
|
5
|
+
secondary: git@bitbucket.org:destructuring/tnargav-aws
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
# 0.3.0 (September 2, 2013)
|
2
|
+
|
3
|
+
* Parallelize multi-machine up on Vagrant 1.2+
|
4
|
+
* Show proper configuration errors if an invalid configuration key
|
5
|
+
is used.
|
6
|
+
* Request confirmation on `vagrant destroy`, like normal VirtualBox + Vagrant.
|
7
|
+
* If user data is configured, output is shown on "vagrant up" that
|
8
|
+
it is being set.
|
9
|
+
* Add EIP support (GH #65)
|
10
|
+
* Add block device mapping support (GH #93)
|
11
|
+
* README improvements (GH #120)
|
12
|
+
* Fix missing locale message (GH #73)
|
13
|
+
* SyncFolders creates hostpath if it doesn't exist and `:create` option is set (GH #17)
|
14
|
+
* Add IAM Instance Profile support (GH #68)
|
15
|
+
* Add shutdown behavior support (GH #125,#131)
|
16
|
+
|
1
17
|
# 0.2.2 (April 18, 2013)
|
2
18
|
|
3
19
|
* Fix crashing bug with incorrect provisioner arguments.
|
data/Gemfile
CHANGED
@@ -6,5 +6,5 @@ group :development do
|
|
6
6
|
# We depend on Vagrant for development, but we don't add it as a
|
7
7
|
# gem dependency because we expect to be installed within the
|
8
8
|
# Vagrant environment itself using `vagrant plugin`.
|
9
|
-
gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
|
9
|
+
gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => "v1.2.7"
|
10
10
|
end
|
data/README.md
CHANGED
@@ -108,6 +108,10 @@ This provider exposes quite a few provider-specific configuration options:
|
|
108
108
|
* `security_groups` - An array of security groups for the instance. If this
|
109
109
|
instance will be launched in VPC, this must be a list of security group
|
110
110
|
IDs.
|
111
|
+
* `iam_instance_profile_arn` - The Amazon resource name (ARN) of the IAM Instance
|
112
|
+
Profile to associate with the instance
|
113
|
+
* `iam_instance_profile_name` - The name of the IAM Instance Profile to associate
|
114
|
+
with the instance
|
111
115
|
* `subnet_id` - The subnet to boot the instance into, for VPC.
|
112
116
|
* `tags` - A hash of tags to set on the machine.
|
113
117
|
* `use_iam_profile` - If true, will use [IAM profiles](http://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html)
|
@@ -173,6 +177,43 @@ the remote machine over SSH.
|
|
173
177
|
This is good enough for all built-in Vagrant provisioners (shell,
|
174
178
|
chef, and puppet) to work!
|
175
179
|
|
180
|
+
## Other Examples
|
181
|
+
|
182
|
+
### Tags
|
183
|
+
|
184
|
+
To use tags, simply define a hash of key/value for the tags you want to associate to your instance, like:
|
185
|
+
|
186
|
+
```ruby
|
187
|
+
Vagrant.configure("2") do |config|
|
188
|
+
# ... other stuff
|
189
|
+
|
190
|
+
config.vm.provider "aws" do |aws|
|
191
|
+
aws.tags = {
|
192
|
+
'Name' => 'Some Name',
|
193
|
+
'Some Key' => 'Some Value'
|
194
|
+
}
|
195
|
+
end
|
196
|
+
end
|
197
|
+
```
|
198
|
+
|
199
|
+
### User data
|
200
|
+
|
201
|
+
You can specify user data for the instance being booted.
|
202
|
+
|
203
|
+
```ruby
|
204
|
+
Vagrant.configure("2") do |config|
|
205
|
+
# ... other stuff
|
206
|
+
|
207
|
+
config.vm.provider "aws" do |aws|
|
208
|
+
# Option 1: a single string
|
209
|
+
aws.user_data = "#!/bin/bash\necho 'got user data' > /tmp/user_data.log\necho"
|
210
|
+
|
211
|
+
# Option 2: use a file
|
212
|
+
aws.user_data = File.read("user_data.txt")
|
213
|
+
end
|
214
|
+
end
|
215
|
+
```
|
216
|
+
|
176
217
|
## Development
|
177
218
|
|
178
219
|
To work on the `vagrant-aws` plugin, clone this repository out, and use
|
@@ -191,8 +232,11 @@ $ bundle exec rake
|
|
191
232
|
If those pass, you're ready to start developing the plugin. You can test
|
192
233
|
the plugin without installing it into your Vagrant environment by just
|
193
234
|
creating a `Vagrantfile` in the top level of this directory (it is gitignored)
|
194
|
-
|
195
|
-
|
235
|
+
and add the following line to your `Vagrantfile`
|
236
|
+
```ruby
|
237
|
+
Vagrant.require_plugin "vagrant-aws"
|
238
|
+
```
|
239
|
+
Use bundler to execute Vagrant:
|
196
240
|
```
|
197
241
|
$ bundle exec vagrant up --provider=aws
|
198
242
|
```
|
data/lib/vagrant-aws/action.rb
CHANGED
@@ -11,9 +11,15 @@ module VagrantPlugins
|
|
11
11
|
# This action is called to terminate the remote machine.
|
12
12
|
def self.action_destroy
|
13
13
|
Vagrant::Action::Builder.new.tap do |b|
|
14
|
-
b.use
|
15
|
-
|
16
|
-
|
14
|
+
b.use Call, DestroyConfirm do |env, b2|
|
15
|
+
if env[:result]
|
16
|
+
b2.use ConfigValidate
|
17
|
+
b2.use ConnectAWS
|
18
|
+
b2.use TerminateInstance
|
19
|
+
else
|
20
|
+
b2.use MessageWillNotDestroy
|
21
|
+
end
|
22
|
+
end
|
17
23
|
end
|
18
24
|
end
|
19
25
|
|
@@ -87,6 +93,7 @@ module VagrantPlugins
|
|
87
93
|
# This action is called to bring the box up from nothing.
|
88
94
|
def self.action_up
|
89
95
|
Vagrant::Action::Builder.new.tap do |b|
|
96
|
+
b.use HandleBoxUrl
|
90
97
|
b.use ConfigValidate
|
91
98
|
b.use ConnectAWS
|
92
99
|
b.use Call, IsCreated do |env, b2|
|
@@ -109,6 +116,7 @@ module VagrantPlugins
|
|
109
116
|
autoload :IsCreated, action_root.join("is_created")
|
110
117
|
autoload :MessageAlreadyCreated, action_root.join("message_already_created")
|
111
118
|
autoload :MessageNotCreated, action_root.join("message_not_created")
|
119
|
+
autoload :MessageWillNotDestroy, action_root.join("message_will_not_destroy")
|
112
120
|
autoload :ReadSSHInfo, action_root.join("read_ssh_info")
|
113
121
|
autoload :ReadState, action_root.join("read_state")
|
114
122
|
autoload :RunInstance, action_root.join("run_instance")
|
@@ -26,7 +26,7 @@ module VagrantPlugins
|
|
26
26
|
:region => region
|
27
27
|
}
|
28
28
|
if region_config.use_iam_profile
|
29
|
-
fog_config[:use_iam_profile] =
|
29
|
+
fog_config[:use_iam_profile] = true
|
30
30
|
else
|
31
31
|
fog_config[:aws_access_key_id] = region_config.access_key_id
|
32
32
|
fog_config[:aws_secret_access_key] = region_config.secret_access_key
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module AWS
|
3
|
+
module Action
|
4
|
+
class MessageWillNotDestroy
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
env[:ui].info(I18n.t("vagrant_aws.will_not_destroy", name: env[:machine].name))
|
11
|
+
@app.call(env)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "log4r"
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
require 'vagrant/util/retryable'
|
4
5
|
|
@@ -24,16 +25,21 @@ module VagrantPlugins
|
|
24
25
|
region = env[:machine].provider_config.region
|
25
26
|
|
26
27
|
# Get the configs
|
27
|
-
region_config
|
28
|
-
ami
|
29
|
-
availability_zone
|
30
|
-
instance_type
|
31
|
-
keypair
|
32
|
-
private_ip_address
|
33
|
-
security_groups
|
34
|
-
subnet_id
|
35
|
-
tags
|
36
|
-
user_data
|
28
|
+
region_config = env[:machine].provider_config.get_region_config(region)
|
29
|
+
ami = region_config.ami
|
30
|
+
availability_zone = region_config.availability_zone
|
31
|
+
instance_type = region_config.instance_type
|
32
|
+
keypair = region_config.keypair_name
|
33
|
+
private_ip_address = region_config.private_ip_address
|
34
|
+
security_groups = region_config.security_groups
|
35
|
+
subnet_id = region_config.subnet_id
|
36
|
+
tags = region_config.tags
|
37
|
+
user_data = region_config.user_data
|
38
|
+
block_device_mapping = region_config.block_device_mapping
|
39
|
+
elastic_ip = region_config.elastic_ip
|
40
|
+
terminate_on_shutdown = region_config.terminate_on_shutdown
|
41
|
+
iam_instance_profile_arn = region_config.iam_instance_profile_arn
|
42
|
+
iam_instance_profile_name = region_config.iam_instance_profile_name
|
37
43
|
|
38
44
|
# If there is no keypair then warn the user
|
39
45
|
if !keypair
|
@@ -41,7 +47,7 @@ module VagrantPlugins
|
|
41
47
|
end
|
42
48
|
|
43
49
|
# If there is a subnet ID then warn the user
|
44
|
-
if subnet_id
|
50
|
+
if subnet_id && !elastic_ip
|
45
51
|
env[:ui].warn(I18n.t("vagrant_aws.launch_vpc_warning"))
|
46
52
|
end
|
47
53
|
|
@@ -53,8 +59,15 @@ module VagrantPlugins
|
|
53
59
|
env[:ui].info(" -- Availability Zone: #{availability_zone}") if availability_zone
|
54
60
|
env[:ui].info(" -- Keypair: #{keypair}") if keypair
|
55
61
|
env[:ui].info(" -- Subnet ID: #{subnet_id}") if subnet_id
|
62
|
+
env[:ui].info(" -- IAM Instance Profile ARN: #{iam_instance_profile_arn}") if iam_instance_profile_arn
|
63
|
+
env[:ui].info(" -- IAM Instance Profile Name: #{iam_instance_profile_name}") if iam_instance_profile_name
|
56
64
|
env[:ui].info(" -- Private IP: #{private_ip_address}") if private_ip_address
|
65
|
+
env[:ui].info(" -- Elastic IP: #{elastic_ip}") if elastic_ip
|
66
|
+
env[:ui].info(" -- User Data: yes") if user_data
|
57
67
|
env[:ui].info(" -- Security Groups: #{security_groups.inspect}") if !security_groups.empty?
|
68
|
+
env[:ui].info(" -- User Data: #{user_data}") if user_data
|
69
|
+
env[:ui].info(" -- Block Device Mapping: #{block_device_mapping}") if block_device_mapping
|
70
|
+
env[:ui].info(" -- Terminate On Shutdown: #{terminate_on_shutdown}")
|
58
71
|
|
59
72
|
begin
|
60
73
|
options = {
|
@@ -64,10 +77,13 @@ module VagrantPlugins
|
|
64
77
|
:key_name => keypair,
|
65
78
|
:private_ip_address => private_ip_address,
|
66
79
|
:subnet_id => subnet_id,
|
80
|
+
:iam_instance_profile_arn => iam_instance_profile_arn,
|
81
|
+
:iam_instance_profile_name => iam_instance_profile_name,
|
67
82
|
:tags => tags,
|
68
|
-
:user_data => user_data
|
83
|
+
:user_data => user_data,
|
84
|
+
:block_device_mapping => block_device_mapping,
|
85
|
+
:instance_initiated_shutdown_behavior => terminate_on_shutdown == true ? "terminate" : nil
|
69
86
|
}
|
70
|
-
|
71
87
|
if !security_groups.empty?
|
72
88
|
security_group_key = options[:subnet_id].nil? ? :groups : :security_group_ids
|
73
89
|
options[security_group_key] = security_groups
|
@@ -85,6 +101,10 @@ module VagrantPlugins
|
|
85
101
|
raise
|
86
102
|
rescue Fog::Compute::AWS::Error => e
|
87
103
|
raise Errors::FogError, :message => e.message
|
104
|
+
rescue Excon::Errors::HTTPStatusError => e
|
105
|
+
raise Errors::InternalFogError,
|
106
|
+
:error => e.message,
|
107
|
+
:response => e.response.body
|
88
108
|
end
|
89
109
|
|
90
110
|
# Immediately save the ID since it is created at this point.
|
@@ -115,6 +135,12 @@ module VagrantPlugins
|
|
115
135
|
|
116
136
|
@logger.info("Time to instance ready: #{env[:metrics]["instance_ready_time"]}")
|
117
137
|
|
138
|
+
# Allocate and associate an elastic IP if requested
|
139
|
+
if elastic_ip
|
140
|
+
domain = subnet_id ? 'vpc' : 'standard'
|
141
|
+
do_elastic_ip(env, domain, server)
|
142
|
+
end
|
143
|
+
|
118
144
|
if !env[:interrupted]
|
119
145
|
env[:metrics]["instance_ssh_time"] = Util::Timer.time do
|
120
146
|
# Wait for SSH to be ready.
|
@@ -148,6 +174,37 @@ module VagrantPlugins
|
|
148
174
|
end
|
149
175
|
end
|
150
176
|
|
177
|
+
def do_elastic_ip(env, domain, server)
|
178
|
+
allocation = env[:aws_compute].allocate_address(domain)
|
179
|
+
if allocation.body['publicIp'].nil?
|
180
|
+
@logger.debug("Could not allocate Elastic IP.")
|
181
|
+
return nil
|
182
|
+
end
|
183
|
+
@logger.debug("Public IP #{allocation.body['publicIp']}")
|
184
|
+
|
185
|
+
# Associate the address and save the metadata to a hash
|
186
|
+
if domain == 'vpc'
|
187
|
+
# VPC requires an allocation ID to assign an IP
|
188
|
+
association = env[:aws_compute].associate_address(server.id, nil, nil, allocation.body['allocationId'])
|
189
|
+
h = { :allocation_id => allocation.body['allocationId'], :association_id => association.body['associationId'], :public_ip => allocation.body['publicIp'] }
|
190
|
+
else
|
191
|
+
# Standard EC2 instances only need the allocated IP address
|
192
|
+
association = env[:aws_compute].associate_address(server.id, allocation.body['publicIp'])
|
193
|
+
h = { :public_ip => allocation.body['publicIp'] }
|
194
|
+
end
|
195
|
+
|
196
|
+
if !association.body['return']
|
197
|
+
@logger.debug("Could not associate Elastic IP.")
|
198
|
+
return nil
|
199
|
+
end
|
200
|
+
|
201
|
+
# Save this IP to the data dir so it can be released when the instance is destroyed
|
202
|
+
ip_file = env[:machine].data_dir.join('elastic_ip')
|
203
|
+
ip_file.open('w+') do |f|
|
204
|
+
f.write(h.to_json)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
151
208
|
def terminate(env)
|
152
209
|
destroy_env = env.dup
|
153
210
|
destroy_env.delete(:interrupted)
|
@@ -39,6 +39,17 @@ module VagrantPlugins
|
|
39
39
|
:hostpath => hostpath,
|
40
40
|
:guestpath => guestpath))
|
41
41
|
|
42
|
+
# Create the host path if it doesn't exist and option flag is set
|
43
|
+
if data[:create]
|
44
|
+
begin
|
45
|
+
FileUtils::mkdir_p(hostpath)
|
46
|
+
rescue => err
|
47
|
+
raise Errors::MkdirError,
|
48
|
+
:hostpath => hostpath,
|
49
|
+
:err => err
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
42
53
|
# Create the guest path
|
43
54
|
env[:machine].communicate.sudo("mkdir -p '#{guestpath}'")
|
44
55
|
env[:machine].communicate.sudo(
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "log4r"
|
2
|
+
require "json"
|
2
3
|
|
3
4
|
module VagrantPlugins
|
4
5
|
module AWS
|
@@ -17,9 +18,29 @@ module VagrantPlugins
|
|
17
18
|
env[:ui].info(I18n.t("vagrant_aws.terminating"))
|
18
19
|
server.destroy
|
19
20
|
env[:machine].id = nil
|
21
|
+
|
22
|
+
# Release the elastic IP
|
23
|
+
ip_file = env[:machine].data_dir.join('elastic_ip')
|
24
|
+
if ip_file.file?
|
25
|
+
release_address(env,ip_file.read)
|
26
|
+
ip_file.delete
|
27
|
+
end
|
20
28
|
|
21
29
|
@app.call(env)
|
22
30
|
end
|
31
|
+
|
32
|
+
# Release an elastic IP address
|
33
|
+
def release_address(env,eip)
|
34
|
+
h = JSON.parse(eip)
|
35
|
+
# Use association_id and allocation_id for VPC, use public IP for EC2
|
36
|
+
if h['association_id']
|
37
|
+
env[:aws_compute].disassociate_address(nil,h['association_id'])
|
38
|
+
env[:aws_compute].release_address(h['allocation_id'])
|
39
|
+
else
|
40
|
+
env[:aws_compute].disassociate_address(h['public_ip'])
|
41
|
+
env[:aws_compute].release_address(h['public_ip'])
|
42
|
+
end
|
43
|
+
end
|
23
44
|
end
|
24
45
|
end
|
25
46
|
end
|
data/lib/vagrant-aws/config.rb
CHANGED
@@ -39,6 +39,11 @@ module VagrantPlugins
|
|
39
39
|
# @return [String]
|
40
40
|
attr_accessor :private_ip_address
|
41
41
|
|
42
|
+
# Acquire and attach an elastic IP address (VPC).
|
43
|
+
#
|
44
|
+
# @return [Boolean]
|
45
|
+
attr_accessor :elastic_ip
|
46
|
+
|
42
47
|
# The name of the AWS region in which to create the instance.
|
43
48
|
#
|
44
49
|
# @return [String]
|
@@ -65,6 +70,18 @@ module VagrantPlugins
|
|
65
70
|
# @return [Array<String>]
|
66
71
|
attr_accessor :security_groups
|
67
72
|
|
73
|
+
# The Amazon resource name (ARN) of the IAM Instance Profile
|
74
|
+
# to associate with the instance.
|
75
|
+
#
|
76
|
+
# @return [String]
|
77
|
+
attr_accessor :iam_instance_profile_arn
|
78
|
+
|
79
|
+
# The name of the IAM Instance Profile to associate with
|
80
|
+
# the instance.
|
81
|
+
#
|
82
|
+
# @return [String]
|
83
|
+
attr_accessor :iam_instance_profile_name
|
84
|
+
|
68
85
|
# The subnet ID to launch the machine into (VPC).
|
69
86
|
#
|
70
87
|
# @return [String]
|
@@ -86,23 +103,38 @@ module VagrantPlugins
|
|
86
103
|
# @return [String]
|
87
104
|
attr_accessor :user_data
|
88
105
|
|
106
|
+
# Block device mappings
|
107
|
+
#
|
108
|
+
# @return [Array<Hash>]
|
109
|
+
attr_accessor :block_device_mapping
|
110
|
+
|
111
|
+
# Indicates whether an instance stops or terminates when you initiate shutdown from the instance
|
112
|
+
#
|
113
|
+
# @return [bool]
|
114
|
+
attr_accessor :terminate_on_shutdown
|
115
|
+
|
89
116
|
def initialize(region_specific=false)
|
90
|
-
@access_key_id
|
91
|
-
@ami
|
92
|
-
@availability_zone
|
117
|
+
@access_key_id = UNSET_VALUE
|
118
|
+
@ami = UNSET_VALUE
|
119
|
+
@availability_zone = UNSET_VALUE
|
93
120
|
@instance_ready_timeout = UNSET_VALUE
|
94
|
-
@instance_type
|
95
|
-
@keypair_name
|
96
|
-
@private_ip_address
|
97
|
-
@region
|
98
|
-
@endpoint
|
99
|
-
@version
|
100
|
-
@secret_access_key
|
101
|
-
@security_groups
|
102
|
-
@subnet_id
|
103
|
-
@tags
|
104
|
-
@user_data
|
105
|
-
@use_iam_profile
|
121
|
+
@instance_type = UNSET_VALUE
|
122
|
+
@keypair_name = UNSET_VALUE
|
123
|
+
@private_ip_address = UNSET_VALUE
|
124
|
+
@region = UNSET_VALUE
|
125
|
+
@endpoint = UNSET_VALUE
|
126
|
+
@version = UNSET_VALUE
|
127
|
+
@secret_access_key = UNSET_VALUE
|
128
|
+
@security_groups = UNSET_VALUE
|
129
|
+
@subnet_id = UNSET_VALUE
|
130
|
+
@tags = {}
|
131
|
+
@user_data = UNSET_VALUE
|
132
|
+
@use_iam_profile = UNSET_VALUE
|
133
|
+
@block_device_mapping = []
|
134
|
+
@elastic_ip = UNSET_VALUE
|
135
|
+
@iam_instance_profile_arn = UNSET_VALUE
|
136
|
+
@iam_instance_profile_name = UNSET_VALUE
|
137
|
+
@terminate_on_shutdown = UNSET_VALUE
|
106
138
|
|
107
139
|
# Internal state (prefix with __ so they aren't automatically
|
108
140
|
# merged)
|
@@ -169,6 +201,10 @@ module VagrantPlugins
|
|
169
201
|
# Merge in the tags
|
170
202
|
result.tags.merge!(self.tags)
|
171
203
|
result.tags.merge!(other.tags)
|
204
|
+
|
205
|
+
# Merge block_device_mapping
|
206
|
+
result.block_device_mapping |= self.block_device_mapping
|
207
|
+
result.block_device_mapping |= other.block_device_mapping
|
172
208
|
end
|
173
209
|
end
|
174
210
|
|
@@ -193,6 +229,9 @@ module VagrantPlugins
|
|
193
229
|
# Default the private IP to nil since VPC is not default
|
194
230
|
@private_ip_address = nil if @private_ip_address == UNSET_VALUE
|
195
231
|
|
232
|
+
# Acquire an elastic IP if requested
|
233
|
+
@elastic_ip = nil if @elastic_ip == UNSET_VALUE
|
234
|
+
|
196
235
|
# Default region is us-east-1. This is sensible because AWS
|
197
236
|
# generally defaults to this as well.
|
198
237
|
@region = "us-east-1" if @region == UNSET_VALUE
|
@@ -206,12 +245,19 @@ module VagrantPlugins
|
|
206
245
|
# Subnet is nil by default otherwise we'd launch into VPC.
|
207
246
|
@subnet_id = nil if @subnet_id == UNSET_VALUE
|
208
247
|
|
248
|
+
# IAM Instance profile arn/name is nil by default.
|
249
|
+
@iam_instance_profile_arn = nil if @iam_instance_profile_arn == UNSET_VALUE
|
250
|
+
@iam_instance_profile_name = nil if @iam_instance_profile_name == UNSET_VALUE
|
251
|
+
|
209
252
|
# By default we don't use an IAM profile
|
210
253
|
@use_iam_profile = false if @use_iam_profile == UNSET_VALUE
|
211
254
|
|
212
255
|
# User Data is nil by default
|
213
256
|
@user_data = nil if @user_data == UNSET_VALUE
|
214
257
|
|
258
|
+
# default false
|
259
|
+
@terminate_on_shutdown = false if @terminate_on_shutdown == UNSET_VALUE
|
260
|
+
|
215
261
|
# Compile our region specific configurations only within
|
216
262
|
# NON-REGION-SPECIFIC configurations.
|
217
263
|
if !@__region_specific
|
@@ -238,7 +284,7 @@ module VagrantPlugins
|
|
238
284
|
end
|
239
285
|
|
240
286
|
def validate(machine)
|
241
|
-
errors =
|
287
|
+
errors = _detected_errors
|
242
288
|
|
243
289
|
errors << I18n.t("vagrant_aws.config.region_required") if @region.nil?
|
244
290
|
|
data/lib/vagrant-aws/errors.rb
CHANGED
@@ -11,6 +11,10 @@ module VagrantPlugins
|
|
11
11
|
error_key(:fog_error)
|
12
12
|
end
|
13
13
|
|
14
|
+
class InternalFogError < VagrantAWSError
|
15
|
+
error_key(:internal_fog_error)
|
16
|
+
end
|
17
|
+
|
14
18
|
class InstanceReadyTimeout < VagrantAWSError
|
15
19
|
error_key(:instance_ready_timeout)
|
16
20
|
end
|
@@ -18,6 +22,10 @@ module VagrantPlugins
|
|
18
22
|
class RsyncError < VagrantAWSError
|
19
23
|
error_key(:rsync_error)
|
20
24
|
end
|
25
|
+
|
26
|
+
class MkdirError < VagrantAWSError
|
27
|
+
error_key(:mkdir_error)
|
28
|
+
end
|
21
29
|
end
|
22
30
|
end
|
23
31
|
end
|
data/lib/vagrant-aws/plugin.rb
CHANGED
data/lib/vagrant-aws/version.rb
CHANGED
data/locales/en.yml
CHANGED
@@ -28,6 +28,9 @@ en:
|
|
28
28
|
Warning! The AWS provider doesn't support any of the Vagrant
|
29
29
|
high-level network configurations (`config.vm.network`). They
|
30
30
|
will be silently ignored.
|
31
|
+
will_not_destroy: |-
|
32
|
+
The instance '%{name}' will not be destroyed, since the confirmation
|
33
|
+
was declined.
|
31
34
|
|
32
35
|
config:
|
33
36
|
access_key_id_required: |-
|
@@ -47,18 +50,30 @@ en:
|
|
47
50
|
below:
|
48
51
|
|
49
52
|
%{message}
|
53
|
+
internal_fog_error: |-
|
54
|
+
There was an error talking to AWS. The error message is shown
|
55
|
+
below:
|
56
|
+
|
57
|
+
Error: %{error}
|
58
|
+
Response: %{response}
|
50
59
|
instance_ready_timeout: |-
|
51
60
|
The instance never became "ready" in AWS. The timeout currently
|
52
61
|
set waiting for the instance to become ready is %{timeout} seconds.
|
53
62
|
Please verify that the machine properly boots. If you need more time
|
54
63
|
set the `instance_ready_timeout` configuration on the AWS provider.
|
55
64
|
rsync_error: |-
|
56
|
-
There was an error when
|
65
|
+
There was an error when attempting to rsync a share folder.
|
57
66
|
Please inspect the error message below for more info.
|
58
67
|
|
59
68
|
Host path: %{hostpath}
|
60
69
|
Guest path: %{guestpath}
|
61
70
|
Error: %{stderr}
|
71
|
+
mkdir_error: |-
|
72
|
+
There was an error when attempting to create a shared host folder.
|
73
|
+
Please inspect the error message below for more info.
|
74
|
+
|
75
|
+
Host path: %{hostpath}
|
76
|
+
Error: %{err}
|
62
77
|
|
63
78
|
states:
|
64
79
|
short_not_created: |-
|
@@ -71,3 +86,9 @@ en:
|
|
71
86
|
long_running: |-
|
72
87
|
The EC2 instance is running. To stop this machine, you can run
|
73
88
|
`vagrant halt`. To destroy the machine, you can run `vagrant destroy`.
|
89
|
+
|
90
|
+
short_pending: |-
|
91
|
+
pending
|
92
|
+
long_pending: |-
|
93
|
+
The EC2 instance is still being initialized. To destroy this machine,
|
94
|
+
you can run `vagrant destroy`.
|
@@ -26,9 +26,14 @@ describe VagrantPlugins::AWS::Config do
|
|
26
26
|
its("secret_access_key") { should be_nil }
|
27
27
|
its("security_groups") { should == [] }
|
28
28
|
its("subnet_id") { should be_nil }
|
29
|
+
its("iam_instance_profile_arn") { should be_nil }
|
30
|
+
its("iam_instance_profile_name") { should be_nil }
|
29
31
|
its("tags") { should == {} }
|
30
32
|
its("user_data") { should be_nil }
|
31
33
|
its("use_iam_profile") { should be_false }
|
34
|
+
its("block_device_mapping") {should == [] }
|
35
|
+
its("elastic_ip") { should be_nil }
|
36
|
+
its("terminate_on_shutdown") { should == false }
|
32
37
|
end
|
33
38
|
|
34
39
|
describe "overriding defaults" do
|
@@ -39,8 +44,9 @@ describe VagrantPlugins::AWS::Config do
|
|
39
44
|
[:access_key_id, :ami, :availability_zone, :instance_ready_timeout,
|
40
45
|
:instance_type, :keypair_name,
|
41
46
|
:region, :secret_access_key, :security_groups,
|
42
|
-
:subnet_id, :tags,
|
43
|
-
:
|
47
|
+
:subnet_id, :tags, :elastic_ip, :terminate_on_shutdown,
|
48
|
+
:iam_instance_profile_arn, :iam_instance_profile_name,
|
49
|
+
:use_iam_profile, :user_data, :block_device_mapping].each do |attribute|
|
44
50
|
|
45
51
|
it "should not default #{attribute} if overridden" do
|
46
52
|
instance.send("#{attribute}=".to_sym, "foo")
|
@@ -182,15 +188,19 @@ describe VagrantPlugins::AWS::Config do
|
|
182
188
|
let(:first) { described_class.new }
|
183
189
|
let(:second) { described_class.new }
|
184
190
|
|
185
|
-
it "should merge the tags" do
|
191
|
+
it "should merge the tags and block_device_mappings" do
|
186
192
|
first.tags["one"] = "one"
|
187
193
|
second.tags["two"] = "two"
|
194
|
+
first.block_device_mapping = [{:one => "one"}]
|
195
|
+
second.block_device_mapping = [{:two => "two"}]
|
188
196
|
|
189
197
|
third = first.merge(second)
|
190
198
|
third.tags.should == {
|
191
199
|
"one" => "one",
|
192
200
|
"two" => "two"
|
193
201
|
}
|
202
|
+
third.block_device_mapping.index({:one => "one"}).should_not be_nil
|
203
|
+
third.block_device_mapping.index({:two => "two"}).should_not be_nil
|
194
204
|
end
|
195
205
|
end
|
196
206
|
end
|
metadata
CHANGED
@@ -1,102 +1,99 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: tnargav-aws
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
version: 0.3.0
|
6
10
|
platform: ruby
|
7
|
-
authors:
|
11
|
+
authors:
|
8
12
|
- Mitchell Hashimoto
|
9
13
|
autorequire:
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
|
17
|
+
date: 2013-09-23 00:00:00 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: fog
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 1.10.0
|
22
|
-
type: :runtime
|
23
22
|
prerelease: false
|
24
|
-
|
25
|
-
|
26
|
-
requirements:
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
27
25
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 10
|
30
|
+
- 0
|
29
31
|
version: 1.10.0
|
30
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
31
35
|
name: rake
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :development
|
39
36
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
name: rspec-core
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 2.12.2
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
54
44
|
type: :development
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec-core
|
55
48
|
prerelease: false
|
56
|
-
|
57
|
-
|
58
|
-
requirements:
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
59
51
|
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 2
|
55
|
+
- 12
|
56
|
+
- 2
|
61
57
|
version: 2.12.2
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: rspec-expectations
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 2.12.1
|
70
58
|
type: :development
|
59
|
+
version_requirements: *id003
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: rspec-expectations
|
71
62
|
prerelease: false
|
72
|
-
|
73
|
-
|
74
|
-
requirements:
|
63
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
75
65
|
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
-
|
79
|
-
|
80
|
-
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ~>
|
84
|
-
- !ruby/object:Gem::Version
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 2
|
69
|
+
- 12
|
70
|
+
- 1
|
85
71
|
version: 2.12.1
|
86
72
|
type: :development
|
73
|
+
version_requirements: *id004
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: rspec-mocks
|
87
76
|
prerelease: false
|
88
|
-
|
89
|
-
|
90
|
-
requirements:
|
77
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
91
79
|
- - ~>
|
92
|
-
- !ruby/object:Gem::Version
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
segments:
|
82
|
+
- 2
|
83
|
+
- 12
|
84
|
+
- 1
|
93
85
|
version: 2.12.1
|
86
|
+
type: :development
|
87
|
+
version_requirements: *id005
|
94
88
|
description: Enables Vagrant to manage machines in EC2 and VPC.
|
95
89
|
email: mitchell@hashicorp.com
|
96
90
|
executables: []
|
91
|
+
|
97
92
|
extensions: []
|
93
|
+
|
98
94
|
extra_rdoc_files: []
|
99
|
-
|
95
|
+
|
96
|
+
files:
|
100
97
|
- CHANGELOG.md
|
101
98
|
- dummy.box
|
102
99
|
- example_box/metadata.json
|
@@ -106,6 +103,7 @@ files:
|
|
106
103
|
- lib/vagrant-aws/action/is_created.rb
|
107
104
|
- lib/vagrant-aws/action/message_already_created.rb
|
108
105
|
- lib/vagrant-aws/action/message_not_created.rb
|
106
|
+
- lib/vagrant-aws/action/message_will_not_destroy.rb
|
109
107
|
- lib/vagrant-aws/action/read_ssh_info.rb
|
110
108
|
- lib/vagrant-aws/action/read_state.rb
|
111
109
|
- lib/vagrant-aws/action/run_instance.rb
|
@@ -130,28 +128,37 @@ files:
|
|
130
128
|
- vagrant-aws.gemspec
|
131
129
|
- .gitignore
|
132
130
|
- .gitsetup.yml
|
131
|
+
has_rdoc: true
|
133
132
|
homepage: http://www.vagrantup.com
|
134
133
|
licenses: []
|
134
|
+
|
135
135
|
post_install_message:
|
136
136
|
rdoc_options: []
|
137
|
-
|
137
|
+
|
138
|
+
require_paths:
|
138
139
|
- lib
|
139
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
requirements:
|
148
|
-
- -
|
149
|
-
- !ruby/object:Gem::Version
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
segments:
|
145
|
+
- 0
|
146
|
+
version: "0"
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
segments:
|
152
|
+
- 1
|
153
|
+
- 3
|
154
|
+
- 6
|
150
155
|
version: 1.3.6
|
151
156
|
requirements: []
|
157
|
+
|
152
158
|
rubyforge_project: vagrant-aws
|
153
|
-
rubygems_version: 1.
|
159
|
+
rubygems_version: 1.3.6
|
154
160
|
signing_key:
|
155
161
|
specification_version: 3
|
156
162
|
summary: Enables Vagrant to manage machines in EC2 and VPC.
|
157
163
|
test_files: []
|
164
|
+
|