File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed
Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -4,9 +4,8 @@ resource "aws_iam_group" "admin" {
44
55resource "aws_iam_user" "user" {
66 for_each = toset (var. user_names )
7-
8- name = each. value
9- tags = var. tags
7+ name = each. value
8+ tags = var. tags
109}
1110
1211resource "aws_iam_group_membership" "membership" {
@@ -16,8 +15,7 @@ resource "aws_iam_group_membership" "membership" {
1615}
1716
1817resource "aws_iam_group_policy_attachment" "admin_policy" {
19- for_each = toset (var. policy_arns )
20-
18+ for_each = toset (var. policy_arns )
2119 group = aws_iam_group. admin . name
2220 policy_arn = each. value
2321}
@@ -36,14 +34,26 @@ resource "aws_iam_group_policy_attachment" "deny_no_mfa_attach" {
3634
3735data "aws_iam_policy_document" "deny_without_mfa" {
3836 statement {
37+ sid = " DenyAllExceptMfaAndPwdWhenNoMFA"
3938 effect = " Deny"
40- actions = [" *" ]
39+
40+ not_actions = [
41+ " iam:GetUser" ,
42+ " iam:ListMFADevices" ,
43+ " iam:ListVirtualMFADevices" ,
44+ " iam:CreateVirtualMFADevice" ,
45+ " iam:EnableMFADevice" ,
46+ " iam:ResyncMFADevice" ,
47+ " iam:DeactivateMFADevice" ,
48+ " iam:ChangePassword" ,
49+ " sts:GetSessionToken"
50+ ]
4151 resources = [" *" ]
4252
4353 condition {
4454 test = " BoolIfExists"
4555 variable = " aws:MultiFactorAuthPresent"
46- values = [" false" ]
56+ values = [" false" ]
4757 }
4858 }
4959}
You can’t perform that action at this time.
0 commit comments