Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inline policy deprecation #380

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions cluster_iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,27 @@ resource "aws_iam_role" "eks_cluster_role" {
count = length(var.cluster_role_arn) == 0 ? 1 : 0
name = "${var.iam_role_name_prefix}EksCluster-${var.name}"
assume_role_policy = data.aws_iam_policy_document.eks_assume_role_policy.json
}

resource "aws_iam_role_policy" "deny_log_group_creation" {
count = length(var.cluster_role_arn) == 0 ? 1 : 0
name = "DenyLogGroupCreation"
role = aws_iam_role.eks_cluster_role[0].id

# Resources running on the cluster are still generating logs when destroying the module resources
# which results in the log group being re-created even after Terraform destroys it. Removing the
# ability for the cluster role to create the log group prevents this log group from being re-created
# outside of Terraform due to services still generating logs during destroy process
inline_policy {
name = "DenyLogGroupCreation"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = ["logs:CreateLogGroup"]
Effect = "Deny"
Resource = "*"
},
]
})
}
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = ["logs:CreateLogGroup"]
Effect = "Deny"
Resource = "*"
},
]
})
}

data "aws_iam_policy_document" "eks_assume_role_policy" {
Expand Down
93 changes: 51 additions & 42 deletions examples/cluster/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.