Skip to content

Instantly share code, notes, and snippets.

View NathanielInman's full-sized avatar
🎯
Focusing

Nathaniel Inman NathanielInman

🎯
Focusing
View GitHub Profile
@NathanielInman
NathanielInman / aws-auth.sh
Created January 22, 2021 18:53
aws-auth.sh allows MFA for aws-cli
#!/bin/bash
# A script that makes it easier to use the AWS CLI with MFA enabled. It fetches your temporary AWS STS credentials and
# writes text to stdout that exports those credentials as the proper environment variables for use with the AWS CLI.
set -e
readonly SCRIPT_NAME=$(basename "$0")
readonly EMPTY_VAL="__EMPTY__"
readonly DEFAULT_MFA_TOKEN_DURATION_SECONDS=43200 # 12 hours
readonly DEFAULT_ROLE_DURATION_SECONDS=43200 # 12 hours