1313# v1alpha API tag "karpenter.sh/provisioner-name" and to manage the EC2 Instance Profile
1414# created by the EKS cluster component.
1515#
16- # WARNING: it is important that the SID values do not conflict with the SID values in the
17- # controller-policy.tf file, otherwise they will be overwritten.
16+ # We create a separate policy and attach it separately to the Karpenter controller role
17+ # because the main policy is near the 6,144 character limit for an IAM policy, and
18+ # adding this to it can push it over. See:
19+ # https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html#reference_iam-quotas-entities
1820#
1921
2022locals {
@@ -35,10 +37,10 @@ locals {
3537 ],
3638 "Condition": {
3739 "StringEquals": {
38- "aws :ResourceTag/kubernetes.io /cluster/ ${ local . eks_cluster_id } ": "owned "
40+ "ec2 :ResourceTag/karpenter.k8s.aws /cluster": " ${ local . eks_cluster_id } "
3941 },
4042 "StringLike": {
41- "aws :ResourceTag/karpenter.sh/provisioner-name": "*"
43+ "ec2 :ResourceTag/karpenter.sh/provisioner-name": "*"
4244 }
4345 }
4446 },
@@ -65,3 +67,23 @@ locals {
6567 }
6668 EndOfPolicy
6769}
70+
71+ # We create a separate policy and attach it separately to the Karpenter controller role
72+ # because the main policy is near the 6,144 character limit for an IAM policy, and
73+ # adding this to it can push it over. See:
74+ # https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html#reference_iam-quotas-entities
75+ resource "aws_iam_policy" "v1alpha" {
76+ count = local. enabled ? 1 : 0
77+
78+ name = " ${ module . this . id } -v1alpha"
79+ description = " Legacy Karpenter controller policy for v1alpha workloads"
80+ policy = local. controller_policy_v1alpha_json
81+ tags = module. this . tags
82+ }
83+
84+ resource "aws_iam_role_policy_attachment" "v1alpha" {
85+ count = local. enabled ? 1 : 0
86+
87+ role = module. karpenter . service_account_role_name
88+ policy_arn = one (aws_iam_policy. v1alpha [* ]. arn )
89+ }
0 commit comments