MFA With CLI

To use MFA but with CLI, we call

aws sts get-session-token --serial-number arn-of-mfa-device --token-code mfa-code --duration-seconds 3600

This will return a json format with

{
	"credentials": {
		"SecretAccessKey": "",
		"SessionToken": "",
		"Expiration": "",
		"AccessKeyId": "",
	}
}

After doing this, we can fill this information into AWS CLI Profile

open ~/.aws/credentials

add

aws_session_token=....