From a3daf640c018ab33ab108c32a851a22549320eaa Mon Sep 17 00:00:00 2001 From: hiromi-ogawa Date: Wed, 30 Oct 2024 12:06:19 +0900 Subject: [PATCH] Use inline policy for v1beta to avoid resource recreation This is a cherry-picked commit with changes in #372 --- modules/karpenter/controller_iam.tf | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/modules/karpenter/controller_iam.tf b/modules/karpenter/controller_iam.tf index 803b436..fc83c46 100644 --- a/modules/karpenter/controller_iam.tf +++ b/modules/karpenter/controller_iam.tf @@ -289,15 +289,10 @@ data "aws_iam_policy_document" "karpenter_controller_v1_alpha" { } } -resource "aws_iam_role_policy_attachment" "karpenter_controller_v1_beta" { - count = var.v1beta ? 1 : 0 - role = aws_iam_role.karpenter_controller.id - policy_arn = aws_iam_policy.karpenter_controller_v1_beta[0].arn -} - -resource "aws_iam_policy" "karpenter_controller_v1_beta" { +resource "aws_iam_role_policy" "karpenter_controller_v1_beta" { count = var.v1beta ? 1 : 0 - name = "${var.cluster_config.iam_policy_name_prefix}KarpenterController-v1beta-${var.cluster_config.name}" + name = "KarpenterController-v1beta" + role = aws_iam_role.karpenter_controller.id policy = data.aws_iam_policy_document.karpenter_controller_v1_beta.json }