Skip to content

Commit

Permalink
require mfa auth for deletion of mfa device (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
russelltsherman authored and osterman committed Dec 26, 2018
1 parent c810a48 commit 6738f2f
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ data "aws_iam_policy_document" "manage_mfa" {
count = "${local.enabled ? 1 : 0}"

statement {
sid = "AllowUsersToCreateEnableResyncDeleteTheirOwnVirtualMFADevice"
sid = "AllowUsersToCreateEnableResyncTheirOwnVirtualMFADevice"

actions = [
"iam:CreateVirtualMFADevice",
"iam:EnableMFADevice",
"iam:ResyncMFADevice",
"iam:DeleteVirtualMFADevice",
]

resources = [
Expand Down Expand Up @@ -77,6 +76,25 @@ data "aws_iam_policy_document" "manage_mfa" {
}
}

statement {
sid = "AllowUsersToDeleteTheirOwnVirtualMFADevice"

actions = [
"iam:DeleteVirtualMFADevice",
]

resources = [
"arn:aws:iam::${data.aws_caller_identity.current.account_id}:mfa/&{aws:username}",
"arn:aws:iam::${data.aws_caller_identity.current.account_id}:user/&{aws:username}",
]

condition {
test = "Bool"
variable = "aws:MultiFactorAuthPresent"
values = ["true"]
}
}

statement {
sid = "AllowUsersToListMFADevicesandUsersForConsole"

Expand Down

0 comments on commit 6738f2f

Please sign in to comment.