Skip to content

Commit e93d207

Browse files
committed
fix(cw-loggroup): added deny in eks cluster role to fix cw-loggroup recreate in cleanup/deletion
Signed-off-by: Christopher Haar <[email protected]>
1 parent 284b038 commit e93d207

File tree

2 files changed

+44
-6
lines changed

2 files changed

+44
-6
lines changed

README.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,17 @@ Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraf
134134

135135
| Name | Version |
136136
|------|---------|
137-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.56.0 |
138-
| <a name="provider_http"></a> [http](#provider\_http) | >= 2.4.1 |
139-
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | >= 1.11.1 |
140-
| <a name="provider_local"></a> [local](#provider\_local) | >= 1.4 |
137+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.59.0 |
138+
| <a name="provider_http"></a> [http](#provider\_http) | 2.4.1 |
139+
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | 2.5.0 |
140+
| <a name="provider_local"></a> [local](#provider\_local) | 2.1.0 |
141141

142142
## Modules
143143

144144
| Name | Source | Version |
145145
|------|--------|---------|
146-
| <a name="module_fargate"></a> [fargate](#module\_fargate) | ./modules/fargate | |
147-
| <a name="module_node_groups"></a> [node\_groups](#module\_node\_groups) | ./modules/node_groups | |
146+
| <a name="module_fargate"></a> [fargate](#module\_fargate) | ./modules/fargate | n/a |
147+
| <a name="module_node_groups"></a> [node\_groups](#module\_node\_groups) | ./modules/node_groups | n/a |
148148

149149
## Resources
150150

@@ -157,12 +157,14 @@ Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraf
157157
| [aws_iam_instance_profile.workers](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_instance_profile) | resource |
158158
| [aws_iam_instance_profile.workers_launch_template](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_instance_profile) | resource |
159159
| [aws_iam_openid_connect_provider.oidc_provider](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_openid_connect_provider) | resource |
160+
| [aws_iam_policy.cluster_deny_log_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
160161
| [aws_iam_policy.cluster_elb_sl_role_creation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
161162
| [aws_iam_role.cluster](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
162163
| [aws_iam_role.workers](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
163164
| [aws_iam_role_policy_attachment.cluster_AmazonEKSClusterPolicy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
164165
| [aws_iam_role_policy_attachment.cluster_AmazonEKSServicePolicy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
165166
| [aws_iam_role_policy_attachment.cluster_AmazonEKSVPCResourceControllerPolicy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
167+
| [aws_iam_role_policy_attachment.cluster_deny_log_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
166168
| [aws_iam_role_policy_attachment.cluster_elb_sl_role_creation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
167169
| [aws_iam_role_policy_attachment.workers_AmazonEC2ContainerRegistryReadOnly](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
168170
| [aws_iam_role_policy_attachment.workers_AmazonEKSWorkerNodePolicy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
@@ -191,6 +193,7 @@ Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraf
191193
| [aws_iam_instance_profile.custom_worker_group_iam_instance_profile](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_instance_profile) | data source |
192194
| [aws_iam_instance_profile.custom_worker_group_launch_template_iam_instance_profile](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_instance_profile) | data source |
193195
| [aws_iam_policy_document.cluster_assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
196+
| [aws_iam_policy_document.cluster_deny_log_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
194197
| [aws_iam_policy_document.cluster_elb_sl_role_creation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
195198
| [aws_iam_policy_document.workers_assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
196199
| [aws_iam_role.custom_cluster_iam_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_role) | data source |

main.tf

+35
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,38 @@ resource "aws_iam_role_policy_attachment" "cluster_elb_sl_role_creation" {
195195
policy_arn = aws_iam_policy.cluster_elb_sl_role_creation[0].arn
196196
role = local.cluster_iam_role_name
197197
}
198+
199+
/*
200+
Adding a policy to cluster IAM role that deny permissions to logs:CreateLogGroup
201+
it is not needed since we create the log group ourselve in this module, and it is causing trouble during cleanup/deletion
202+
*/
203+
204+
data "aws_iam_policy_document" "cluster_deny_log_group" {
205+
count = var.manage_cluster_iam_resources && var.create_eks ? 1 : 0
206+
207+
statement {
208+
effect = "Deny"
209+
actions = [
210+
"logs:CreateLogGroup"
211+
]
212+
resources = ["*"]
213+
}
214+
}
215+
216+
resource "aws_iam_policy" "cluster_deny_log_group" {
217+
count = var.manage_cluster_iam_resources && var.create_eks ? 1 : 0
218+
219+
name_prefix = "${var.cluster_name}-deny-log-group"
220+
description = "Deny CreateLogGroup"
221+
policy = data.aws_iam_policy_document.cluster_deny_log_group[0].json
222+
path = var.iam_path
223+
224+
tags = var.tags
225+
}
226+
227+
resource "aws_iam_role_policy_attachment" "cluster_deny_log_group" {
228+
count = var.manage_cluster_iam_resources && var.create_eks ? 1 : 0
229+
230+
policy_arn = aws_iam_policy.cluster_deny_log_group[0].arn
231+
role = local.cluster_iam_role_name
232+
}

0 commit comments

Comments
 (0)