@@ -43,8 +43,7 @@ data "aws_iam_policy_document" "karpenter_controller" {
4343 " ec2:CreateLaunchTemplate" ,
4444 " ec2:CreateFleet" ,
4545 " ec2:DescribeSpotPriceHistory" ,
46- " pricing:GetProducts" ,
47- " iam:ListInstanceProfiles"
46+ " pricing:GetProducts"
4847 ]
4948 resources = [" *" ]
5049 }
@@ -85,6 +84,85 @@ data "aws_iam_policy_document" "karpenter_controller" {
8584 ]
8685 }
8786
87+ statement {
88+ sid = " AllowScopedInstanceProfileCreationActions"
89+ effect = " Allow"
90+ actions = [
91+ " iam:CreateInstanceProfile"
92+ ]
93+ resources = [" *" ]
94+ condition {
95+ test = " StringEquals"
96+ variable = " aws:RequestTag/kubernetes.io/cluster/${ aws_eks_cluster . cluster . name } "
97+ values = [" owned" ]
98+ }
99+ condition {
100+ test = " StringLike"
101+ variable = " aws:RequestTag/karpenter.k8s.aws/ec2nodeclass"
102+ values = [" *" ]
103+ }
104+ }
105+
106+ statement {
107+ sid = " AllowScopedInstanceProfileTagActions"
108+ effect = " Allow"
109+ actions = [
110+ " iam:TagInstanceProfile"
111+ ]
112+ resources = [" *" ]
113+ condition {
114+ test = " StringEquals"
115+ variable = " aws:ResourceTag/kubernetes.io/cluster/${ aws_eks_cluster . cluster . name } "
116+ values = [" owned" ]
117+ }
118+ condition {
119+ test = " StringEquals"
120+ variable = " aws:RequestTag/kubernetes.io/cluster/${ aws_eks_cluster . cluster . name } "
121+ values = [" owned" ]
122+ }
123+ condition {
124+ test = " StringLike"
125+ variable = " aws:ResourceTag/karpenter.k8s.aws/ec2nodeclass"
126+ values = [" *" ]
127+ }
128+ condition {
129+ test = " StringLike"
130+ variable = " aws:RequestTag/karpenter.k8s.aws/ec2nodeclass"
131+ values = [" *" ]
132+ }
133+ }
134+
135+ statement {
136+ sid = " AllowScopedInstanceProfileActions"
137+ effect = " Allow"
138+ actions = [
139+ " iam:AddRoleToInstanceProfile" ,
140+ " iam:RemoveRoleFromInstanceProfile" ,
141+ " iam:DeleteInstanceProfile"
142+ ]
143+ resources = [" *" ]
144+ condition {
145+ test = " StringEquals"
146+ variable = " aws:ResourceTag/kubernetes.io/cluster/${ aws_eks_cluster . cluster . name } "
147+ values = [" owned" ]
148+ }
149+ condition {
150+ test = " StringLike"
151+ variable = " aws:ResourceTag/karpenter.k8s.aws/ec2nodeclass"
152+ values = [" *" ]
153+ }
154+ }
155+
156+ statement {
157+ sid = " AllowInstanceProfileReadListActions"
158+ effect = " Allow"
159+ actions = [
160+ " iam:ListInstanceProfiles" ,
161+ " iam:GetInstanceProfile"
162+ ]
163+ resources = [" *" ]
164+ }
165+
88166 # SQS permissions for interruption handling (not in the base guide but required when using interruptionQueue)
89167 statement {
90168 sid = " SQSPolling"
0 commit comments