question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Profile is not read when defined as assuming role

See original GitHub issue

Describe the bug

I am not sure if this is a bug or a feature request, I am assuming it is a bug because this is a rather standard behaviour even with other sdks (the python one works fine, for example).

The issue is that in my shared credentials file I have a security profile we use to log into our centralized IAM account and from there we can assume roles into other accounts with proper permissions. The way we do this is by defining them as profiles with the security profile as source profile and indicating what role to asume in the config shared filed.

For example, this profile is present in my .aws/credentials file

[securityiam]
aws_access_key_id=AKIAXXXXXX
aws_secret_access_key=XXXXXX

and then, in my .aws/config file I have configured this profile

[profile my-new-profile]
source_profile=securityiam
role_arn=arn:aws:iam::XXXX:role/my_role_to_asume

I wold expect that by creating an S3 client specifying the analytics-dev profile it would automatically handle the role assumption logic but it seems that it does not. I get the following error:

ProviderError: Profile my-new-profile requires a role to be assumed, but no role assumption callback was provided.

We would like to avoid, if possible, having dependencies in code with the role to be used because, when deployed, it will authenticate using the service metadata. Having to add a role assumption logic seems adding logic we should not need (and with other sdks we actually don’t need). Whatever extra code we need to add is code only intended for development purposes and we would like to keep it to the minimum.

Probably I am missing something, let me know if you need further information.

Thanks!

Your environment

SDK version number

@aws-sdk/credential-provider-node@3.15.0 @aws-sdk/client-s3@3.15.0

Is the issue in the browser/Node.js/ReactNative?

Node.js

Details of the browser/Node.js/ReactNative version

node v14.16.0

Steps to reproduce

Add a profile into .aws/credentials and a profile as explained above in .aws/config. Create a client to s3 that tries to list buckets

import { S3, ListBucketsCommandInput } from "@aws-sdk/client-s3";
import { defaultProvider } from "@aws-sdk/credential-provider-node";


const credentials = defaultProvider({profile: "my-new-profile"});

const client = new S3({credentials: credentials, region: "us-east-1"});

const buckets = client.listBuckets({}, (err, data) => {
    if (err) console.log(err, err.stack); // an error occurred
    else     console.log(data);           // successful response
});
console.log(buckets);

Observed behavior

The call returns an error that states:

ProviderError: Profile analytics-dev requires a role to be assumed, but no role assumption callback was provided.

Expected behavior

The S3 client returns the list of bucket using the assumed role as stated in the config file.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ajredniwjacommented, Jun 10, 2021

It is released, I will try to reproduce this and discuss it with the team as well.

0reactions
github-actions[bot]commented, Sep 2, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot IAM assume role errors "AccessDenied ... - AWS
I tried to assume a cross-account AWS Identity and Access Management (IAM) role. However, I received an error similar to the following:.
Read more >
Top 5 Common AWS IAM Errors you Need to Fix | A Cloud Guru
1. AccessDeniedException – I Can't Assume a Role ... IAM roles can be used to delegate access to your AWS resources across different...
Read more >
assume-role — AWS CLI 2.9.9 Command Reference
To assume a role from a different account, your Amazon Web Services account must be trusted by the role. The trust relationship is...
Read more >
How enable access to AWS STS AssumeRole - Stack Overflow
I ran a test with the policy simulator, to sts assume role, pointing to the ARN of role created at step one; and...
Read more >
AWS IAM Role Chaining - In Plain English
An IAM role has a trust policy that defines which conditions must be met to allow the assuming identity to assume the role....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found