Skip to content

Commit 49ae221

Browse files
authored
create mfa enforcement policy and add it to existing groups (#128)
1 parent f4f3364 commit 49ae221

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

terraform/aws-custom-policies.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ module "aws_custom_policies" {
44
"IAMServicesSupervisor" = {
55
description = "Policy granting IAM services admins permissions to make changes to user accounts"
66
filename = "level-4-iam-services-supervisor-policy.json"
7+
},
8+
"EnforceMFAForUsers" = {
9+
description = "Policy enforcing MFA for devops security users"
10+
filename = "enforce-mfa-for-users-policy.json"
711
}
812
}
913
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"Version": "2012-10-17",
3+
"Statement": [
4+
{
5+
"Sid": "EnforceMFAForUsers",
6+
"Effect": "Deny",
7+
"NotAction": [
8+
"iam:CreateVirtualMFADevice",
9+
"iam:EnableMFADevice",
10+
"iam:GetUser",
11+
"iam:GetMFADevice",
12+
"iam:ListMFADevices",
13+
"iam:ListVirtualMFADevices",
14+
"iam:ResyncMFADevice",
15+
"sts:GetSessionToken"
16+
],
17+
"Resource": "*",
18+
"Condition": {
19+
"BoolIfExists": {
20+
"aws:MultiFactorAuthPresent": "false"
21+
}
22+
}
23+
}
24+
]
25+
}

terraform/aws-groups.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module "iam_read_only_group" {
55
group_name = "read-only-group"
66
policy_arn = {
77
"ReadOnlyAccess" = "arn:aws:iam::aws:policy/ReadOnlyAccess",
8-
"IAMUserChangePassword" = "arn:aws:iam::aws:policy/IAMUserChangePassword"
8+
"IAMUserChangePassword" = "arn:aws:iam::aws:policy/IAMUserChangePassword",
9+
"EnforceMFAForUsers" = module.aws_custom_policies.policy_arns["EnforceMFAForUsers"]
910
}
1011
}
1112

@@ -15,7 +16,8 @@ module "iam_services_supervisor_group" {
1516

1617
group_name = "iam-services-supervisor-group"
1718
policy_arn = {
18-
"IAMServicesSupervisor" = module.aws_custom_policies.policy_arns["IAMServicesSupervisor"]
19+
"IAMServicesSupervisor" = module.aws_custom_policies.policy_arns["IAMServicesSupervisor"],
20+
"EnforceMFAForUsers" = module.aws_custom_policies.policy_arns["EnforceMFAForUsers"]
1921
}
2022
}
2123

0 commit comments

Comments
 (0)