As a user of an AWS account, use this zsh script to assume any given IAM role within the account.
Includes step of MFA authentication.
# Replace {role} with the ARN of the target IAM role.
# Then run:
role_arn={role} source aws_assume_role.sh
Script will export AWS_ACCESS_KEY
, AWS_SECRET_ACCESS_KEY
and AWS_SESSION_TOKEN
in the current shell.
Further info on temporary security credentials can be found here.