Credentials

Using a central IAM account

~/.aws/credentials

[source]
aws_access_key_id = ...
aws_secret_access_key = ...

~/.aws/config

[profile [PROFILE NAME]]
region = eu-west-1
output = json
role_arn = arn:aws:iam::[ACCOUNT ID]:role/[ROLE NAME]
mfa_serial = arn:aws:iam::[ACCOUNT ID]:mfa/[IAM USERNAME]
source_profile = source
export AWS_PROFILE=PROFILE NAME

Script for switching using credentials

#!/usr/bin/env bash

echo "Enter the account for which you want to export credentials and [enter]"
read account

export AWS_ACCESS_KEY_ID=$(aws configure get $account.aws_access_key_id)
export AWS_SECRET_ACCESS_KEY=$(aws configure get $account.aws_secret_access_key)
export AWS_REGION=$(aws configure get $account.region)