2
votes

I try to use aws cli with docker images.

the command line like :

slu@machine:/c/work/dfsi$ export AWS_PROFILE=role-development
slu@machine:/c/work/dfsi$ aws ecr get-login

An error occurred

(AccessDeniedException) when calling the GetAuthorizationToken operation: User: arn:aws:iam::XXXXXXXXXXXX:user/slu is not authorized to perform: ecr:GetAuthorizationToken on resource: *

but I can do:

aws ecr get-login --profile=role-development

What I want to do isn't obviously write --profile and try to do it with hidden --profile variable?

How to do that?

3
are you asking where the default profile credentials are stored on your computer? Whatever credentials are set within that file under [default] will be used.David Rees
I do not ask default profile, I want to change profile to role-development as default profile, How to do it?user504909
I think there is another issue here. This seems to be the correct method of switching profiles. Is there anything else about your setup that might be causing this issue?David Rees
when you type 'export' do you see your profile configuration correctly specified? does that name match up exactly with your ~/.aws/config?David Rees
Yes the role-development is defined in ~/.aws/config. I just want to use that profile instead of default profile just like in aws console switch roleuser504909

3 Answers

4
votes

The below environmental variable is working for me as expected.

AWS_DEFAULT_PROFILE=profile-name
2
votes
  • step1: echo $AWS_DEFAULT_PROFILE to see what's your environment variable.
  • step2: export AWS_DEFAULT_PROFILE=your_aws_default_profile_name

To verify, simply run aws iam list-users to see what comes back based on your profile.

0
votes

If you have AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY set then they will override anything in AWS_PROFILE and AWS_DEFAULT_PROFILE