Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see what profile is default with CLI?

Given I have the following config file:

[default] aws_access_key_id=default_access_key aws_secret_access_key=default_secret_key  [profile testing] aws_access_key_id=testing_access_key aws_secret_access_key=testing_secret_key region=us-west-2 

And given the name of my default profile is foo

What CLI commands do I need to type in to get the name of my default profile. Something like:

$ aws describe-default-profile  {     ...     "default_profile_name": 'foo' } 

Or list all profiles and it ouputs the default too:

$ aws list-all-profiles  {     [{         ...         profile_name: 'foo',         "is_default": true     }] } 

There is a get-instance-profile on iam (docs), but it requires the name of the profile be specified:

$ aws iam get-instance-profile --instance-profile-name ExampleInstanceProfile 
like image 700
Green Avatar asked Nov 04 '16 05:11

Green


People also ask

How do I change the default profile in AWS CLI?

In order to set the name for the default AWS CLI profile, set the AWS_PROFILE environment variable to the name of the profile stored in your credentials and config files, e.g. admin for a named profile, or default for the default profile. Copied!

How do I find my default region in AWS CLI?

aws configure get region will get you the current region at that point in your script. If you are using a profile, then type aws configure get region --profile $PROFILE_NAME . This will return the region of the configuration, not the region that your aws cli invocation was performed from.

How do you check if AWS CLI is configured?

Use the describe-configuration-recorder-status command to check that the AWS Config has started recording the configurations of the supported AWS resources existing in your account. The recorded configurations are delivered to the specified delivery channel.


1 Answers

You can run aws configure list to list your current profile

List the AWS CLI configuration data. This command will show you the current configuration data. For each configuration item, it will show you the value, where the configuration value was retrieved, and the configuration variable name. For example, if you provide the AWS region in an environment variable, this command will show you the name of the region you've configured, it will tell you that this value came from an environment variable, and it will tell you the name of the environment variable.

To show your current configuration values:

      $ aws configure list             Name                    Value             Type    Location             ----                    -----             ----    --------          profile                <not set>             None    None       access_key     ****************ABCD      config_file    ~/.aws/config       secret_key     ****************ABCD      config_file    ~/.aws/config           region                us-west-2              env    AWS_DEFAULT_REGION 

If you want to review your configuration for a specific profile, you can run aws configure list --profile foo

like image 147
Frederic Henri Avatar answered Sep 22 '22 01:09

Frederic Henri