Skip to content

Commit c799fec

Browse files
authored
fix: Use customer managed policy instead of inline policy for cluster_elb_sl_role_creation (#1039)
NOTE: The usage of customer managed policy, not an inline policy, for the `cluster_elb_sl_role_creation policy` is common for "enterprise" AWS users to disallow inline policies with an SCP rule for auditing-related reasons, and this accomplishes the same thing.
1 parent 93614b3 commit c799fec

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cluster.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,15 @@ data "aws_iam_policy_document" "cluster_elb_sl_role_creation" {
158158
}
159159
}
160160

161-
resource "aws_iam_role_policy" "cluster_elb_sl_role_creation" {
161+
resource "aws_iam_policy" "cluster_elb_sl_role_creation" {
162162
count = var.manage_cluster_iam_resources && var.create_eks ? 1 : 0
163163
name_prefix = "${var.cluster_name}-elb-sl-role-creation"
164-
role = local.cluster_iam_role_name
164+
description = "Permissions for EKS to create AWSServiceRoleForElasticLoadBalancing service-linked role"
165165
policy = data.aws_iam_policy_document.cluster_elb_sl_role_creation[0].json
166166
}
167+
168+
resource "aws_iam_role_policy_attachment" "cluster_elb_sl_role_creation" {
169+
count = var.manage_cluster_iam_resources && var.create_eks ? 1 : 0
170+
policy_arn = aws_iam_policy.cluster_elb_sl_role_creation[0].arn
171+
role = local.cluster_iam_role_name
172+
}

0 commit comments

Comments
 (0)