Working with MFA‑enabled AWS accounts from the CLI can be painful; this post walks through the small tool I built to make that workflow bearable.
Using MFA enabled AWS accounts & CLI
TD;LR
Simplify your life when using MFA-enabled accounts with AWS profiles by installing this command-line tool.
Install awsmfa from npm or fork the project on GitHub.
Managing MFA credentials
Enforcing multi-factor authentication (MFA) on AWS accounts is a security best practice that can provide some
usability hurdles for engineers that rely on the SDK and AWS command line tools to get work done.
The typical workflow for working with MFA-enabled accounts is to request a temporary session using the AWS STS service. The STS service will then return a session token which includes temporary credentials as well as a session token. Depending on the use case these data can then be used either in a profile definition, environment variables or as arguments to call AWS Apis that require MFA.