AWS: CLI named profiles
Tags: aws
Published: 2019-03-22 15:22:14

---
title: AWS: CLI named profiles
published: true
tags: AWS
canonical_url: https://rtfm.co.ua/en/aws-cli-named-profiles/
---

![aws-logo-square-02](https://rtfm.co.ua/wp-content/uploads/2014/11/aws-logo-square-02-e1417012834176-1.png)AWS CLI supports so-called _[named profiles](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html)_ stored in the configuration file `.aws/config` and `~/.aws/credentials` file with keys which by default contains the… Well – the “_default_” profile.

An additional profile can be added using the `aws configure` command with the `--profile` option.

Here is an example of such file with already existing two profiles:

```
$ cat ~/.aws/credentials
[default]
aws_access_key_id = AKI***6GA
aws_secret_access_key = cbd***M6W
[TAG]
aws_access_key_id = AKI***FJQ
aws_secret_access_key = 6T***4sG
```

To add a new one – execute:

```
$ aws configure --profile example
AWS Access Key ID [None]: 123456
AWS Secret Access Key [None]: 0123456789
Default region name [None]: eu-west-1
Default output format [None]: json
```

Check them now:

```
$ cat ~/.aws/credentials
[default]
aws_access_key_id = AKI***6GA
aws_secret_access_key = cbd***M6W
[TAG]
aws_access_key_id = AKI***FJQ
aws_secret_access_key = 6T/***4sG
[example]
aws_access_key_id = 123456
aws_secret_access_key = 0123456789
```

And config-file:

```
$ cat ~/.aws/config
[default]
aws_access_key_id = AKI***TCQ
region = eu-west-1
output = json
aws_secret_access_key = nSD***dj+
[preview]
cloudfront = true
[profile example]
output = json
region = eu-west-1
```
  
To run a command using one of those profiles – use the `--profile` option.

For example, using the _default_ one:

```
$ aws s3 ls
2016-05-10 12:35:03 elasticbeanstalk-eu-west-1
2016-08-29 17:45:34 rtfmbackups
2016-09-15 18:01:53 static-site-example
```

And similarly but using the _TAG_ profile:

```
$ aws s3 ls --profile TAG
2016-04-06 18:16:08 elasticbeanstalk-eu-west-1
2016-03-15 18:42:46 elasticbeanstalk-us-west-2
2016-05-09 19:22:16 profile-dev.connected.com
2016-05-09 21:09:40 profile-staging.connected.com
2016-08-17 16:02:28 profileapp.connected.com
2015-07-23 01:05:41 tag-cms-media-dev
2015-08-13 00:22:57 tag-cms-media-prod
2015-08-13 00:23:12 tag-cms-media-staging
2015-07-14 21:31:41 tag-ecs-config
...
```

Also, you can set your default profile using the `$AWS_DEFAULT_PROFILE` environment variable:

```
$ export AWS_DEFAULT_PROFILE=TAG
$ aws s3 ls
2016-04-06 18:16:08 elasticbeanstalk-eu-west-1
2016-03-15 18:42:46 elasticbeanstalk-us-west-2
2016-05-09 19:22:16 profile-dev.connected.com
2016-05-09 21:09:40 profile-staging.connected.com
2016-08-17 16:02:28 profileapp.connected.com
...
```

More details in the [documentation>>>](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-multiple-profiles).

### Similar posts

- <small>10/17/2016</small> [AWS: The bucket you are attempting to access must be addressed using the specified endpoint.](https://rtfm.co.ua/aws-the-bucket-you-are-attempting-to-access-must-be-addressed-using-the-specified-endpoint/)<small> (0)</small>  
- <small>09/13/2017</small> [AWS: CloudFront – обновить SSL сертификат](https://rtfm.co.ua/aws-cloudfront-update-ssl-sertifikat/)<small> (0)</small>  
- <small>09/30/2017</small> [AWS: миграция RTFM 2.1 – CloudFormation для EC2 c Jenkins](https://rtfm.co.ua/aws-cloudformation-dlya-ec2-c-jenkins/)<small> (0)</small>  
- <small>03/17/2019</small> [Terraform: main commands, state-files, backend storages, and modules in examples on AWS](https://dev.to/setevoy/terraform-main-commands-state-files-backend-storages-and-modules-in-examples-on-aws-5ehb)<small> (0)</small>