Skip to content

Commit 95909ce

Browse files
committed
fix(bootstrap): ensure node role and fargate policies are included in IAM permissions
1 parent 95b1622 commit 95909ce

14 files changed

+40
-4
lines changed

cmd/clusterawsadm/cloudformation/bootstrap/cluster_api_controller.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828

2929
const (
3030
eksClusterPolicyName = "AmazonEKSClusterPolicy"
31+
eksFargatePolicyName = "AmazonEKSFargatePodExecutionRolePolicy"
3132
)
3233

3334
func (t Template) controllersPolicyGroups() []string {
@@ -409,6 +410,14 @@ func (t Template) ControllersPolicyEKS() *iamv1.PolicyDocument {
409410
})
410411
}
411412

413+
allowedGetPolicies := append(iamv1.Resources{
414+
t.generateAWSManagedPolicyARN(eksClusterPolicyName),
415+
}, t.nodeManagedPolicies()...)
416+
417+
if !t.Spec.EKS.Fargate.Disable {
418+
allowedGetPolicies = append(allowedGetPolicies, t.generateAWSManagedPolicyARN(eksFargatePolicyName))
419+
}
420+
412421
statements = append(statements, []iamv1.StatementEntry{
413422
{
414423
Action: allowedIAMActions,
@@ -421,10 +430,8 @@ func (t Template) ControllersPolicyEKS() *iamv1.PolicyDocument {
421430
Action: iamv1.Actions{
422431
"iam:GetPolicy",
423432
},
424-
Resource: iamv1.Resources{
425-
t.generateAWSManagedPolicyARN(eksClusterPolicyName),
426-
},
427-
Effect: iamv1.EffectAllow,
433+
Resource: allowedGetPolicies,
434+
Effect: iamv1.EffectAllow,
428435
},
429436
{
430437
Action: iamv1.Actions{

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/customsuffix.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ Resources:
345345
Effect: Allow
346346
Resource:
347347
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
348+
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
349+
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
348350
- Action:
349351
- eks:DescribeCluster
350352
- eks:ListClusters

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/default.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ Resources:
345345
Effect: Allow
346346
Resource:
347347
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
348+
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
349+
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
348350
- Action:
349351
- eks:DescribeCluster
350352
- eks:ListClusters

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/with_all_secret_backends.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ Resources:
358358
Effect: Allow
359359
Resource:
360360
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
361+
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
362+
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
361363
- Action:
362364
- eks:DescribeCluster
363365
- eks:ListClusters

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/with_allow_assume_role.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ Resources:
350350
Effect: Allow
351351
Resource:
352352
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
353+
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
354+
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
353355
- Action:
354356
- eks:DescribeCluster
355357
- eks:ListClusters

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/with_bootstrap_user.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ Resources:
353353
Effect: Allow
354354
Resource:
355355
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
356+
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
357+
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
356358
- Action:
357359
- eks:DescribeCluster
358360
- eks:ListClusters

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/with_custom_bootstrap_user.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ Resources:
353353
Effect: Allow
354354
Resource:
355355
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
356+
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
357+
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
356358
- Action:
357359
- eks:DescribeCluster
358360
- eks:ListClusters

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/with_different_instance_profiles.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ Resources:
345345
Effect: Allow
346346
Resource:
347347
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
348+
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
349+
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
348350
- Action:
349351
- eks:DescribeCluster
350352
- eks:ListClusters

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/with_eks_console.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ Resources:
345345
Effect: Allow
346346
Resource:
347347
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
348+
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
349+
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
348350
- Action:
349351
- eks:DescribeCluster
350352
- eks:ListClusters

cmd/clusterawsadm/cloudformation/bootstrap/fixtures/with_eks_default_roles.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,10 @@ Resources:
345345
Effect: Allow
346346
Resource:
347347
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
348+
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
349+
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
350+
- arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly
351+
- arn:aws:iam::aws:policy/AmazonEKSFargatePodExecutionRolePolicy
348352
- Action:
349353
- eks:DescribeCluster
350354
- eks:ListClusters

0 commit comments

Comments
 (0)