DrkStr
DrkStr

Reputation: 1932

Get currently set profile in AWS CLI

I have a few profiles set up in my AWS configure file. How do I check what the current profile is set to?

I am not looking to get the value set on the profile: https://docs.aws.amazon.com/cli/latest/reference/configure/get.html

I am not looking for a list of profiles: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configure/list-profiles.html

Question: how do I check my currently active profile in AWS CLI?

Upvotes: 10

Views: 14150

Answers (2)

zacharyclement
zacharyclement

Reputation: 21

I was looking to do the same thing and here is the solution I came up with.

First, I had to understand that when you run an AWS CLI command, to run it with a specific profile, you use aws s3 blahblah --profile myawsprofile

But I wanted to run commands without having to specify my profile each time.

To do this, I looked in my ~/.aws/credentials In here, I can see all my profiles.

I moved the profile I wanted to use into the default position.

Upvotes: 1

maafk
maafk

Reputation: 6906

A good sanity check I use is to run

aws sts get-caller-identity

Based on the docs:

Returns details about the IAM user or role whose credentials are used to call the operation.

Can give you a hint around which profile you currently have set

Upvotes: 26

Related Questions