amazon-archives/aws-sdk-core-ruby

SharedCredentials not loading credentials if profile is a role

Closed this issue · 1 comments

When trying to use Aws::SharedCredentials, I am finding that if the profile is assuming a role, that the access keys are being set to nil.

The file ~/.aws/credentials.

[default]
aws_access_key_id = id
aws_secret_access_key = key

[example]
role_arn = arn:aws:iam::12345678:role/example
source_profile = default

Working:

Aws> credentials = Aws::SharedCredentials.new(profile_name: 'default')
=> #<Aws::SharedCredentials profile_name="default" path="/home/user/.aws/credentials">
Aws> credentials.credentials
=> #<Aws::Credentials access_key_id="id">

Failing:

Aws> credentials = Aws::SharedCredentials.new(profile_name: 'example')
=> #<Aws::SharedCredentials profile_name="example" path="/home/user/.aws/credentials">
Aws> credentials.credentials
=> #<Aws::Credentials access_key_id=nil>

When I try to use the credentials I get the following error:

Aws::CloudFormation::Client.new(credentials: Aws::SharedCredentials.new(profile_name: 'example')).describe_stacks
Aws::Errors::MissingCredentialsError: unable to sign request without credentials set

Is this the correct way to assume a role that is an existing profile? Otherwise, what is the best way to deal with this?

Moved to issue to correct repository.

aws/aws-sdk-ruby#910