Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 763
DrkStr Avatar asked Mar 22 '26 00:03

DrkStr


2 Answers

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

like image 182
maafk Avatar answered Mar 23 '26 12:03

maafk


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.

like image 34
zacharyclement Avatar answered Mar 23 '26 13:03

zacharyclement



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!