How to configure multiple AWS CLI authentication credentials

AWS power users often possess multiple IAM accounts with which they execute terminal commands and CLI operations.

For example, an AWS developer might rely on separate accounts to manage Kubernetes clusters in DEV, PRE-PROD and QA environments. A freelance solution architect might have separate accounts to manage the static S3-hosted websites of the various organization for which they consult.

Unfortunately, when the AWS CLI is installed, only one IAM account is configured. If you need to switch between multiple accounts in the CLI for different tasks, that can be a head-scratcher. Here's how you set it up.

Multiple AWS CLI account credentials

Fortunately, adding multiple AWS CLI account credentials isn't that hard.

This single command creates a new profile for the AWS CLI tool:

aws configure --profile dev

How to switch between CLI accounts

Then, to switch between accounts, simply specify the profile name in the command:

aws --profile dev sts get-caller-identity

For a deeper dive on how to simplify the process to configure multiple IAM accounts with the AWS configuration tool and safely maintain AWS CLI authentication credentials, watch the complete video tutorial.

Cameron McKenzie has been a Java EE software engineer for 20 years. His current specialties include Agile development; DevOps; Spring; and container-based technologies such as Docker, Swarm and Kubernetes.

View All Videos