vagrant-aws 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # 0.1.3 (April 9, 2013)
2
+
3
+ * The `AWS_ACCESS_KEY` and `AWS_SECRET_KEY` will be used if available
4
+ and no specific keys are set in the Vagrantfile. [GH-33]
5
+ * Fix issues with SSH on VPCs, the correct IP is used. [GH-30]
6
+ * Exclude the ".vagrant" directory from rsync.
7
+ * Implement `:disabled` flag support for shared folders. [GH-29]
8
+ * `aws.user_data` to specify user data on the instance. [GH-26]
9
+
1
10
  # 0.1.2 (March 22, 2013)
2
11
 
3
12
  * Choose the proper region when connecting to AWS. [GH-9]
data/README.md CHANGED
@@ -72,6 +72,9 @@ Note that normally a lot of this boilerplate is encoded within the box
72
72
  file, but the box file used for the quick start, the "dummy" box, has
73
73
  no preconfigured defaults.
74
74
 
75
+ If you have issues with SSH connecting, make sure that the instances
76
+ are being launched with a security group that allows SSH access.
77
+
75
78
  ## Box Format
76
79
 
77
80
  Every provider in Vagrant must introduce a custom box format. This
@@ -91,7 +94,8 @@ This provider exposes quite a few provider-specific configuration options:
91
94
  * `ami` - The AMI id to boot, such as "ami-12345678"
92
95
  * `availability_zone` - The availability zone within the region to launch
93
96
  the instance. If nil, it will use the default set by Amazon.
94
- * `instance_type` - The type of instance, such as "m1.small"
97
+ * `instance_type` - The type of instance, such as "m1.small". The default
98
+ value of this if not specified is "m1.small".
95
99
  * `keypair_name` - The name of the keypair to use to bootstrap AMIs
96
100
  which support it.
97
101
  * `private_ip_address` - The private IP address to assign to an instance
@@ -134,7 +138,7 @@ Vagrant.configure("2") do |config|
134
138
  aws.secret_access_key = "bar"
135
139
  aws.region = "us-east-1"
136
140
 
137
- # Simply region config
141
+ # Simple region config
138
142
  aws.region_config "us-east-1", :ami => "ami-12345678"
139
143
 
140
144
  # More comprehensive region config
@@ -35,7 +35,7 @@ module VagrantPlugins
35
35
 
36
36
  # Read the DNS info
37
37
  return {
38
- :host => server.dns_name,
38
+ :host => server.dns_name || server.private_ip_address,
39
39
  :port => config.ssh_port,
40
40
  :private_key_path => config.ssh_private_key_path,
41
41
  :username => config.ssh_username
@@ -34,6 +34,7 @@ module VagrantPlugins
34
34
  security_groups = region_config.security_groups
35
35
  subnet_id = region_config.subnet_id
36
36
  tags = region_config.tags
37
+ user_data = region_config.user_data
37
38
 
38
39
  # If there is no keypair then warn the user
39
40
  if !keypair
@@ -66,7 +67,8 @@ module VagrantPlugins
66
67
  :ssh_port => ssh_port,
67
68
  :private_ip_address => private_ip_address,
68
69
  :subnet_id => subnet_id,
69
- :tags => tags
70
+ :tags => tags,
71
+ :user_data => user_data
70
72
  }
71
73
 
72
74
  if !security_groups.empty?
@@ -2,12 +2,16 @@ require "log4r"
2
2
 
3
3
  require "vagrant/util/subprocess"
4
4
 
5
+ require "vagrant/util/scoped_hash_override"
6
+
5
7
  module VagrantPlugins
6
8
  module AWS
7
9
  module Action
8
10
  # This middleware uses `rsync` to sync the folders over to the
9
11
  # AWS instance.
10
12
  class SyncFolders
13
+ include Vagrant::Util::ScopedHashOverride
14
+
11
15
  def initialize(app, env)
12
16
  @app = app
13
17
  @logger = Log4r::Logger.new("vagrant_aws::action::sync_folders")
@@ -19,6 +23,11 @@ module VagrantPlugins
19
23
  ssh_info = env[:machine].ssh_info
20
24
 
21
25
  env[:machine].config.vm.synced_folders.each do |id, data|
26
+ data = scoped_hash_override(data, :aws)
27
+
28
+ # Ignore disabled shared folders
29
+ next if data[:disabled]
30
+
22
31
  hostpath = File.expand_path(data[:hostpath], env[:root_path])
23
32
  guestpath = data[:guestpath]
24
33
 
@@ -38,6 +47,7 @@ module VagrantPlugins
38
47
  # Rsync over to the guest path using the SSH info
39
48
  command = [
40
49
  "rsync", "--verbose", "--archive", "-z",
50
+ "--exclude", ".vagrant/",
41
51
  "-e", "ssh -p #{ssh_info[:port]} -o StrictHostKeyChecking=no -i '#{ssh_info[:private_key_path]}'",
42
52
  hostpath,
43
53
  "#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]
@@ -7,7 +7,7 @@ module VagrantPlugins
7
7
  class TerminateInstance
8
8
  def initialize(app, env)
9
9
  @app = app
10
- @logger = Log4r::Logger.new("vagrant_aws::action::run_instance")
10
+ @logger = Log4r::Logger.new("vagrant_aws::action::terminate_instance")
11
11
  end
12
12
 
13
13
  def call(env)
@@ -87,6 +87,11 @@ module VagrantPlugins
87
87
  # @return [Hash<String, String>]
88
88
  attr_accessor :tags
89
89
 
90
+ # The user data string
91
+ #
92
+ # @return [String]
93
+ attr_accessor :user_data
94
+
90
95
  def initialize(region_specific=false)
91
96
  @access_key_id = UNSET_VALUE
92
97
  @ami = UNSET_VALUE
@@ -104,6 +109,7 @@ module VagrantPlugins
104
109
  @ssh_username = UNSET_VALUE
105
110
  @subnet_id = UNSET_VALUE
106
111
  @tags = {}
112
+ @user_data = UNSET_VALUE
107
113
 
108
114
  # Internal state (prefix with __ so they aren't automatically
109
115
  # merged)
@@ -174,9 +180,10 @@ module VagrantPlugins
174
180
  end
175
181
 
176
182
  def finalize!
177
- # The access keys default to nil
178
- @access_key_id = nil if @access_key_id == UNSET_VALUE
179
- @secret_access_key = nil if @secret_access_key == UNSET_VALUE
183
+ # Try to get access keys from standard AWS environment variables; they
184
+ # will default to nil if the environment variables are not present.
185
+ @access_key_id = ENV['AWS_ACCESS_KEY'] if @access_key_id == UNSET_VALUE
186
+ @secret_access_key = ENV['AWS_SECRET_KEY'] if @secret_access_key == UNSET_VALUE
180
187
 
181
188
  # AMI must be nil, since we can't default that
182
189
  @ami = nil if @ami == UNSET_VALUE
@@ -210,6 +217,9 @@ module VagrantPlugins
210
217
  # Subnet is nil by default otherwise we'd launch into VPC.
211
218
  @subnet_id = nil if @subnet_id == UNSET_VALUE
212
219
 
220
+ # User Data is nil by default
221
+ @user_data = nil if @user_data == UNSET_VALUE
222
+
213
223
  # Compile our region specific configurations only within
214
224
  # NON-REGION-SPECIFIC configurations.
215
225
  if !@__region_specific
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module AWS
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
@@ -3,6 +3,11 @@ require "vagrant-aws/config"
3
3
  describe VagrantPlugins::AWS::Config do
4
4
  let(:instance) { described_class.new }
5
5
 
6
+ # Ensure tests are not affected by AWS credential environment variables
7
+ before :each do
8
+ ENV.stub(:[] => nil)
9
+ end
10
+
6
11
  describe "defaults" do
7
12
  subject do
8
13
  instance.tap do |o|
@@ -23,6 +28,7 @@ describe VagrantPlugins::AWS::Config do
23
28
  its("ssh_username") { should be_nil }
24
29
  its("subnet_id") { should be_nil }
25
30
  its("tags") { should == {} }
31
+ its("user_data") { should be_nil }
26
32
  end
27
33
 
28
34
  describe "overriding defaults" do
@@ -43,6 +49,35 @@ describe VagrantPlugins::AWS::Config do
43
49
  end
44
50
  end
45
51
 
52
+ describe "getting credentials from environment" do
53
+ context "without EC2 credential environment variables" do
54
+ subject do
55
+ instance.tap do |o|
56
+ o.finalize!
57
+ end
58
+ end
59
+
60
+ its("access_key_id") { should be_nil }
61
+ its("secret_access_key") { should be_nil }
62
+ end
63
+
64
+ context "with EC2 credential environment variables" do
65
+ before :each do
66
+ ENV.stub(:[]).with("AWS_ACCESS_KEY").and_return("access_key")
67
+ ENV.stub(:[]).with("AWS_SECRET_KEY").and_return("secret_key")
68
+ end
69
+
70
+ subject do
71
+ instance.tap do |o|
72
+ o.finalize!
73
+ end
74
+ end
75
+
76
+ its("access_key_id") { should == "access_key" }
77
+ its("secret_access_key") { should == "secret_key" }
78
+ end
79
+ end
80
+
46
81
  describe "region config" do
47
82
  let(:config_access_key_id) { "foo" }
48
83
  let(:config_ami) { "foo" }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-22 00:00:00.000000000 Z
12
+ date: 2013-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog
@@ -142,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  segments:
144
144
  - 0
145
- hash: 1300892683038952165
145
+ hash: 3553654739612910885
146
146
  required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  none: false
148
148
  requirements: