Skip to content

Commit

Permalink
Refs mitchellh#473 Don't lock the AWS region
Browse files Browse the repository at this point in the history
See the mitchellh#484 merge request
  • Loading branch information
rconde-bt committed Dec 2, 2020
1 parent 21f2f05 commit d9800a1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/vagrant-aws/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ def finalize!
if @access_key_id == UNSET_VALUE or @secret_access_key == UNSET_VALUE
@aws_profile = 'default' if @aws_profile == UNSET_VALUE
@aws_dir = ENV['HOME'].to_s + '/.aws/' if @aws_dir == UNSET_VALUE
@region, @access_key_id, @secret_access_key, @session_token = Credentials.new.get_aws_info(@aws_profile, @aws_dir)
@region = UNSET_VALUE if @region.nil?
@aws_region, @access_key_id, @secret_access_key, @session_token = Credentials.new.get_aws_info(@aws_profile, @aws_dir)
@region = @aws_region if @region == UNSET_VALUE and !@aws_region.nil?
else
@aws_profile = nil
@aws_dir = nil
Expand Down
17 changes: 17 additions & 0 deletions spec/vagrant-aws/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,23 @@
its("access_key_id") { should == "AKIdefault" }
its("secret_access_key") { should == "PASSdefault" }
its("session_token") { should be_nil }
its("region") { should == "eu-west-1" }
end

context "with default profile and overriding region" do
subject do
allow(File).to receive(:exist?).and_return(true)
allow(File).to receive(:read).with(filename_cfg).and_return(data_cfg)
allow(File).to receive(:read).with(filename_keys).and_return(data_keys)
instance.region = "eu-central-1"
instance.tap do |o|
o.finalize!
end
end
its("access_key_id") { should == "AKIdefault" }
its("secret_access_key") { should == "PASSdefault" }
its("session_token") { should be_nil }
its("region") { should == "eu-central-1" }
end

context "without any credential environment variables and chosing a profile" do
Expand Down

0 comments on commit d9800a1

Please sign in to comment.