Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support of assume roles from profiles and the load of parameters from parent profile #1092

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 16 additions & 2 deletions aws-sdk-core/lib/aws-sdk-core/shared_credentials.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,30 @@ def default_path

def load_from_path
profile = load_profile
@credentials = Credentials.new(
credentials = Credentials.new(
profile['aws_access_key_id'],
profile['aws_secret_access_key'],
profile['aws_session_token']
)
@credentials = if role_arn = profile['role_arn']
AssumeRoleCredentials.new(
role_session_name: [*('A'..'Z')].sample(16).join,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random name seems a bit strange ... how about "assumed-#{profile_name}-#{ENV['USER']}"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually you propose the cosmetic change. :) If this one is only blocker I'll do it ;)

role_arn: role_arn,
credentials: credentials
).credentials
else
credentials
end
end

def load_profile
if profile = profiles[profile_name]
profile
# Add all options from source profile
if source = profile.delete('source_profile')
profiles[source].merge(profile)
else
profile
end
else
msg = "Profile `#{profile_name}' not found in #{path}"
raise Errors::NoSuchProfileError, msg
Expand Down