跳至内容

Partial credentials found in assume-role, missing: source_profile or credential_source

0

I have configured the IAM user and IAM role within the same AWS account to setup AWS CLI for my team. When i try to use these credentials to run some command, i get the above error in CLI. What should i be doing?

I have given the IAM role trust policy to assume role for anyone in the same AWS account. I have added policy for the IAM user to assume the above IAM role.

~/.aws/credentials 

[regionsadmin]
aws_access_key_id = ******
aws_secret_access_key = ******
~.aws/config
[profile regionsadmin]
region = us-east-1
output = json
source_profile = regionsadmin

[default]
role_arn = arn:aws:iam::****:role/regionsclirole
1 回答
3
已接受的回答

If you refer AWS CLI Configuration Variables documentation, take a look at section Using AWS IAM Roles.

I'm not sure why you'd setup CLI to assume role in same account. Refer re:Post Knowledge Center Article for same account IAM Assume Role CLI.

For cross account setup, your entry should look like as below:

  # In ~/.aws/credentials:
  [regionsadmin]
  aws_access_key_id = ******
  aws_secret_access_key = ******

  # In ~/.aws/config
  [profile crossaccount]
  region = us-east-1
  output = json
  source_profile = regionsadmin
  role_arn=arn:aws:iam::****:role/regionsclirole

For same account setup, your entry should look like as below:

  # In ~/.aws/credentials:
  [regionsadmin]
  aws_access_key_id = ******
  aws_secret_access_key = ******

  # In ~/.aws/config
  [profile crossaccount]
  region = us-east-1
  output = json
  source_profile = regionsadmin
  role_arn=arn:aws:iam::****:role/regionsclirole

Edit:

I just tested this in house and it works absolutely fine as expected even within same account. User for which I saved credentials, had only sts assume role permissions where as the role which it assumed had getsecretvalue permissions. Attaching snapshot for your reference:

Enter image description here

Hope you find this useful.

Comment here if you have additional questions, happy to help.

Abhishek

AWS
专家

已回答 3 年前

AWS
专家

已审核 3 年前

  • Now I'm getting a new error

    Unable to locate credentials. You can configure credentials by running "aws configure".
    
  • I'm curious, why do you need to setup CLI this way as this setup is more suited for cross account. Doesn't sts:assumerole fit more into your requirement as described here.

  • I just tested this in house for same account setup as well, and it worked fine. User for which I saved credentials in credentials file, had only sts assume role permissions where as the role which it assumed had getsecretvalue permissions. I'd suggest you to take a look at your configuration once more and see if you find something incorrect. May be you can paste your config and credentials entry again after masking account and credentials info. I can take another look at your files.

  • Yes, I had followed the same procedure using a different AWS doc. The one you have provided is better. I was able to run the AWS command. Thank you

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。