Last active
May 29, 2021 16:24
-
-
Save serban-petrescu/2a6db271bb3e5860cef80ac21ea51446 to your computer and use it in GitHub Desktop.
BW-AWS: 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
if ((Find-BWField -item $item -name "IS_ROOT") -eq "true") { | |
$mfaArn = "arn:aws:iam::$($account):mfa/root-account-mfa-device" | |
} else { | |
$mfaArn = "arn:aws:iam::$($account):mfa/$($item.login.username)" | |
} | |
if ($item.login.totp) { | |
$token = bw get totp $id | |
$result = aws sts get-session-token --serial-number $mfaArn --token-code $token ` | |
--duration-seconds $sessionLifetime | ConvertFrom-Json | |
} else { | |
$result = aws sts get-session-token --duration-seconds $sessionLifetime | ConvertFrom-Json | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment