Last active
May 31, 2019 00:52
-
-
Save tom-butler/8cd908bf2ec616662439f70fd2ccdcf6 to your computer and use it in GitHub Desktop.
AWS CLI MFA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[default] | |
region = ap-southeast-2 | |
[profile prod-admin] | |
source_profile = default | |
role_arn = arn:aws:iam::123456789012:role/write | |
mfa_serial = arn:aws:iam::0987654321098:mfa/uname | |
[profile prod-read] | |
source_profile = default | |
role_arn = arn:aws:iam::123456789012:role/read | |
mfa_serial = arn:aws:iam::0987654321098:mfa/uname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ "sts:AssumeRole" ], | |
"Resource": [ | |
"arn:aws:iam::123456789012:role/read", | |
"arn:aws:iam::123456789012:role/write" | |
], | |
"Condition": { | |
"Bool": { | |
"aws:MultiFactorAuthPresent": "true", | |
"aws:SecureTransport": "true" | |
}, | |
"NumericLessThan": { | |
"aws:MultiFactorAuthAge": "14400" | |
} | |
} | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": { | |
"AWS": "arn:aws:iam::0987654321098:user/uname" | |
}, | |
"Action": "sts:AssumeRole", | |
"Condition": { | |
"Bool": { | |
"aws:SecureTransport": "true", | |
"aws:MultiFactorAuthPresent": "true" | |
}, | |
"NumericLessThan": { | |
"aws:MultiFactorAuthAge": "14400" | |
} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will enable you to assume-role x-account and requiring MFA
Prod account: 123456789012
Bastion account: 0987654321098
Install aws-vault
brew cask install aws-vault
In your bastion account create a policy with the value of bastion-assume-role-policy.json create a group called assume-role.
In your Bastion account, create an IAM user for your individual use.
aws-vault add default
.In your production account create a Role that trusts Another AWS Account, enter your bastion account id and force mfa.
Update your ~/.aws/config file with aws-config, you will need to configure the ARNs of roles and MFA
Test it out
aws-vault exec prod-admin --
you will be asked for the password (maybe twice) and the MFA token you created in step 3.Notes:
aws-vault exec prod-admin --no-session --
References:
https://www.worklogapp.com/jp/updates/35
https://github.com/coinbase/assume-role
https://github.com/99designs/aws-vault