Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

SEC-187 Fixes use_iam_profile bug #525

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/vagrant-aws/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,12 @@ def finalize!
# If access_key_id or secret_access_key were not specified in Vagrantfile
# then try to read from environment variables first, and if it fails from
# the AWS folder.
if @access_key_id == UNSET_VALUE or @secret_access_key == UNSET_VALUE
if (@access_key_id == UNSET_VALUE or @secret_access_key == UNSET_VALUE) and @use_iam_profile == 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?
elsif @use_iam_profile != UNSET_VALUE
else
@aws_profile = nil
@aws_dir = nil
Expand Down Expand Up @@ -439,7 +440,7 @@ def validate(machine)

errors << I18n.t("vagrant_aws.config.aws_info_required",
:profile => @aws_profile, :location => @aws_dir) if \
@aws_profile and (@access_key_id.nil? or @secret_access_key.nil? or @region.nil?)
@aws_profile.nil? and (@access_key_id.nil? or @secret_access_key.nil? or @region.nil?)

errors << I18n.t("vagrant_aws.config.region_required") if @region.nil?

Expand Down