Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the default profile variable in aws cli?

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?

like image 930
user504909 Avatar asked Feb 04 '26 23:02

user504909


2 Answers

The below environmental variable is working for me as expected.

AWS_DEFAULT_PROFILE=profile-name
like image 89
mohit Avatar answered Feb 06 '26 14:02

mohit


  • 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.

like image 32
Bin Li Avatar answered Feb 06 '26 14:02

Bin Li



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!