AWS CLI

Note: This document only relates to Mojaloop Devs with access to the private Mojaloop AWS Environment. If you think it belongs somewhere else, please let me know, or move it accordingly.

MFA

Since the end of 2019, we have enforced MFA on all AWS Console Accounts (that is, accounts used by people). This has added some difficulty in using the AWS CLI tools, since aws cli commands will be rejected if a user has valid credentials, but hasn't also

In order to use the aws cli with MFA, you must create 'temporary credentials', that is, an AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY that is valid for a limited amount of time.

Using aws-mfa

aws-mfa is a python tool which helps manage the creation of new credentials automatically.

Follow the Installation guide to install the tool and set up your ~/.aws/credentials and .bashrc files accordingly.

For reference, this is what mine looks like:

#~/.aws/credentials
[mojaloop-long-term]
aws_access_key_id = NONE_OF
aws_secret_access_key = YOUR_BUSINESS
#~/.bashrc
export AWS_PROFILE=mojaloop
export MFA_DEVICE=arn:aws:iam::<insert arn here>
export MFA_STS_DURATION=3600

Example

For example, given a ~/.aws/credentials file of the following:

We can run a simple command to list all buckets (aws s3 ls), and see that it fails.

After setting up aws-mfa:

Last updated

Was this helpful?