Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (5.6k points)
I need to have Multiple AWS profiles so that I can easily modify the setting and credentials, So how to select which profile we want to use when logging in?

When I'm trying to that, it's giving me an error "An error occurred (UnrecognizedClientException) when calling the GetAuthorizationToken operation: The security token included in the request is invalid."

Any solution will be appreciated.

1 Answer

0 votes
by (12.4k points)
edited by

For setting up multiple profiles for AWA login, first, you need do to the following things:

1st, Setup the credential file with your access keys

2nd, the Setup default setting for profiles

3rd, Set the AWS_Profile environment variable

4th, Remove previous AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY

1: ~/.aws/credentials

[default]

aws_access_key_id =

aws_secret_access_key =

[cat]

aws_access_key_id = XXXX

aws_secret_access_key = XXXXXXXXXXXX

[dog]

aws_access_key_id = XXXX

aws_secret_access_key = XXXXXXXXXXXX

2: ~/.aws/config

[default]

region = eu-central-1

[profile cat]

region = us-west-2

[profile dog]

region = ap-northeast-1

3. Select the profile

In bash, this can be done in "~\.bash_profile" by adding a line "export AWS_PROFILE="cat" "

And to switch profile in the terminal, use this "AWS_PROFILE=dog".

4. Remove global Settings

Also, make sure that the environment variables "AWS_ACCESS_KEY_ID" and "AWS_SECRET_ACCESS_KEY" can not be set because the AWS-CLI gives priority to variables over the profiles.

Now you can log in to the AWS service of your choice.

Want to learn more about AWS? Come & join: AWS Certification

Related questions

0 votes
1 answer

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

Browse Categories

...