Create mfa enforcement policy and add it to existing groups#128
Merged
Conversation
|
Terraform plan in terraform Plan: 3 to add, 2 to change, 0 to destroy.Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create
!~ update in-place
Terraform will perform the following actions:
# module.aws_custom_policies.aws_iam_policy.custom_policy["EnforceMFAForUsers"] will be created
+ resource "aws_iam_policy" "custom_policy" {
+ arn = (known after apply)
+ attachment_count = (known after apply)
+ description = "Policy enforcing MFA for devops security users"
+ id = (known after apply)
+ name = "EnforceMFAForUsers"
+ name_prefix = (known after apply)
+ path = "/"
+ policy = jsonencode(
{
+ Statement = [
+ {
+ Condition = {
+ BoolIfExists = {
+ "aws:MultiFactorAuthPresent" = "false"
}
}
+ Effect = "Deny"
+ NotAction = [
+ "iam:CreateVirtualMFADevice",
+ "iam:EnableMFADevice",
+ "iam:GetUser",
+ "iam:GetMFADevice",
+ "iam:ListMFADevices",
+ "iam:ListVirtualMFADevices",
+ "iam:ResyncMFADevice",
+ "sts:GetSessionToken",
]
+ Resource = "*"
+ Sid = "EnforceMFAForUsers"
},
]
+ Version = "2012-10-17"
}
)
+ policy_id = (known after apply)
+ tags_all = (known after apply)
}
# module.iam_oidc_gha_incubator.aws_iam_openid_connect_provider.github_actions will be updated in-place
!~ resource "aws_iam_openid_connect_provider" "github_actions" {
id = "arn:aws:iam::035866691871:oidc-provider/token.actions.githubusercontent.com"
tags = {}
!~ thumbprint_list = [
!~ "d89e3bd43d5d909b47a18977aa9d5ce36cee184c" -> "2b18947a6a9fc7764fd8b5fb18a863b0c6dac24f",
]
# (4 unchanged attributes hidden)
}
# module.iam_oidc_gha_incubator.aws_iam_role.github_actions_oidc will be updated in-place
!~ resource "aws_iam_role" "github_actions_oidc" {
!~ assume_role_policy = jsonencode(
!~ {
!~ Statement = [
!~ {
!~ Condition = {
!~ StringLike = {
!~ "token.actions.githubusercontent.com:sub" = "*******************************************************************************************"
}
# (1 unchanged attribute hidden)
}
# (3 unchanged attributes hidden)
},
- {
- Action = "sts:AssumeRoleWithWebIdentity"
- Condition = {
- StringEquals = {
- "token.actions.githubusercontent.com:aud" = "*****************"
- "token.actions.githubusercontent.com:sub" = "*************************************"
}
}
- Effect = "Allow"
- Principal = {
- Federated = "arn:aws:iam::035866691871:oidc-provider/token.actions.githubusercontent.com"
}
},
]
# (1 unchanged attribute hidden)
}
)
id = "gha-incubator"
name = "gha-incubator"
tags = {}
# (11 unchanged attributes hidden)
}
# module.iam_read_only_group.aws_iam_group_policy_attachment.group_policy_attachment["EnforceMFAForUsers"] will be created
+ resource "aws_iam_group_policy_attachment" "group_policy_attachment" {
+ group = "read-only-group"
+ id = (known after apply)
+ policy_arn = (known after apply)
}
# module.iam_services_supervisor_group.aws_iam_group_policy_attachment.group_policy_attachment["EnforceMFAForUsers"] will be created
+ resource "aws_iam_group_policy_attachment" "group_policy_attachment" {
+ group = "iam-services-supervisor-group"
+ id = (known after apply)
+ policy_arn = (known after apply)
}
Plan: 3 to add, 2 to change, 0 to destroy.
Warning: Argument is deprecated
with module.iam_oidc_gha_incubator.aws_iam_role.github_actions_oidc,
on modules/aws-gha-oidc-providers/main.tf line 54, in resource "aws_iam_role" "github_actions_oidc":
54: managed_policy_arns = var.policy_arns
managed_policy_arns is deprecated. Use the aws_iam_role_policy_attachment
resource instead. If Terraform should exclusively manage all managed policy
attachments (the current behavior of this argument), use the
aws_iam_role_policy_attachments_exclusive resource as well.✅ Plan applied in Apply Terraform changes on merge #29 |
ale210
approved these changes
Aug 14, 2025
Member
|
Great job @gmgonzal , thanks! |
Member
Author
|
My pleasure! I can help update the wiki as well to include information on how to create a session token and update the aws credentials file to authenticate via CLI now that MFA is enabled by default. Is there a wiki I can update with this info? |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #22
What changes did you make?
EnforceMFAForUsers.Why did you make the changes (we will use this info to test)?
New Policy Created
Group Policies Updated
Users without MFA have limited access