Skip to content

Commit

Permalink
fix(bootstrap): ensure node role and fargate policies are included in…
Browse files Browse the repository at this point in the history
… IAM permissions
  • Loading branch information
adammw committed Jan 7, 2025
1 parent 95b1622 commit 95909ce
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

const (
eksClusterPolicyName = "AmazonEKSClusterPolicy"
eksFargatePolicyName = "AmazonEKSFargatePodExecutionRolePolicy"
)

func (t Template) controllersPolicyGroups() []string {
Expand Down Expand Up @@ -409,6 +410,14 @@ func (t Template) ControllersPolicyEKS() *iamv1.PolicyDocument {
})
}

allowedGetPolicies := append(iamv1.Resources{
t.generateAWSManagedPolicyARN(eksClusterPolicyName),
}, t.nodeManagedPolicies()...)

if !t.Spec.EKS.Fargate.Disable {
allowedGetPolicies = append(allowedGetPolicies, t.generateAWSManagedPolicyARN(eksFargatePolicyName))
}

statements = append(statements, []iamv1.StatementEntry{
{
Action: allowedIAMActions,
Expand All @@ -421,10 +430,8 @@ func (t Template) ControllersPolicyEKS() *iamv1.PolicyDocument {
Action: iamv1.Actions{
"iam:GetPolicy",
},
Resource: iamv1.Resources{
t.generateAWSManagedPolicyARN(eksClusterPolicyName),
},
Effect: iamv1.EffectAllow,
Resource: allowedGetPolicies,
Effect: iamv1.EffectAllow,
},
{
Action: iamv1.Actions{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ Resources:
Effect: Allow
Resource:
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
- Action:
- eks:DescribeCluster
- eks:ListClusters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ Resources:
Effect: Allow
Resource:
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
- Action:
- eks:DescribeCluster
- eks:ListClusters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ Resources:
Effect: Allow
Resource:
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
- Action:
- eks:DescribeCluster
- eks:ListClusters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ Resources:
Effect: Allow
Resource:
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
- Action:
- eks:DescribeCluster
- eks:ListClusters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ Resources:
Effect: Allow
Resource:
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
- Action:
- eks:DescribeCluster
- eks:ListClusters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ Resources:
Effect: Allow
Resource:
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
- Action:
- eks:DescribeCluster
- eks:ListClusters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ Resources:
Effect: Allow
Resource:
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
- Action:
- eks:DescribeCluster
- eks:ListClusters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ Resources:
Effect: Allow
Resource:
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
- Action:
- eks:DescribeCluster
- eks:ListClusters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ Resources:
Effect: Allow
Resource:
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
- arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly
- arn:aws:iam::aws:policy/AmazonEKSFargatePodExecutionRolePolicy
- Action:
- eks:DescribeCluster
- eks:ListClusters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ Resources:
Effect: Allow
Resource:
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
- arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly
- Action:
- eks:DescribeCluster
- eks:ListClusters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ Resources:
Effect: Allow
Resource:
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
- Action:
- eks:DescribeCluster
- eks:ListClusters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ Resources:
Effect: Allow
Resource:
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
- Action:
- eks:DescribeCluster
- eks:ListClusters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ Resources:
Effect: Allow
Resource:
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
- Action:
- eks:DescribeCluster
- eks:ListClusters
Expand Down

0 comments on commit 95909ce

Please sign in to comment.