Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Support using the profile name from the AWS_PROFILE env var #4

Open
wants to merge 1 commit into
base: et_knife_ec2
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
2 changes: 1 addition & 1 deletion lib/chef/knife/ec2_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def validate!(keys=[:aws_access_key_id, :aws_secret_access_key])
# aws_secret_access_key = somethingsomethingdarkside

aws_creds = ini_parse(File.read(Chef::Config[:knife][:aws_credential_file]))
profile = Chef::Config[:knife][:aws_profile] || 'default'
profile = Chef::Config[:knife][:aws_profile] || ENV['AWS_PROFILE'] || 'default'
entries = aws_creds.values.first.has_key?("AWSAccessKeyId") ? aws_creds.values.first : aws_creds[profile]

Chef::Config[:knife][:aws_access_key_id] = entries['AWSAccessKeyId'] || entries['aws_access_key_id']
Expand Down