Skip to content

Instantly share code, notes, and snippets.

@serban-petrescu
Last active May 29, 2021 16:24
Show Gist options
  • Save serban-petrescu/2a6db271bb3e5860cef80ac21ea51446 to your computer and use it in GitHub Desktop.
Save serban-petrescu/2a6db271bb3e5860cef80ac21ea51446 to your computer and use it in GitHub Desktop.
BW-AWS: MFA
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