Configuring CLI access

This page shows how to get AWS access from the commandline using your IAM user.

Logging to the AWS console

Login to the AWS console under the customized login page, eg. https://123456.signin.aws.amazon.com/console. This should require you to enter your username/password and your MFA token to login.

Creating access keys for your user

Go to your user in IAM to create access keys.
This can be done at the following URL: https://console.aws.amazon.com/iam/home#/users. Click on your user and go to the tab Security credentials.
Create an access key by clicking on Create access key.
Make sure to download the CSV file with the credentials.

Configuring CLI access

Create a new file ~/.aws/config with the following content:

[profile myorg-master]
mfa_serial = ${MFA_SERIAL}

Make sure to replace ${MFA_SERIAL} with the MFA serial of your user.
Go to your user in IAM to find the correct MFA serial.
This can be done at the following URL: https://console.aws.amazon.com/iam/home#/users. Click on your user and go to the tab Security credentials.

Additionally create a file ~/.aws/credentials with the following content:

[myorg-master]
aws_access_key_id=${AWS_ACCESS_KEY_ID}
aws_secret_access_key=${AWS_SECRET_ACCESS_KEY}

Make sure to replace ${AWS_ACCESS_KEY_ID} and ${AWS_SECRET_ACCESS_KEY} with the access key credentials of your user.

Testing CLI access

Type in the following command to check if CLI access is working:

AWS_PROFILE=myorg-master aws sts get-caller-identity

The response should look as follows:

{
    "UserId": "AISARDABSDJLSFJLFQMRVEVJ",
    "Account": "0123456789",
    "Arn": "arn:aws:iam::0123456789:user/user@domain.org"
}