Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func (t Template) controllersPolicyRoleAttachments() []string {
return attachments
}

func (t Template) controllersTrustPolicy() *iamv1.PolicyDocument {
policyDocument := ec2AssumeRolePolicy()
func (t Template) controllersTrustPolicy(eksEnabled bool) *iamv1.PolicyDocument {
policyDocument := ec2AssumeRolePolicy(eksEnabled)
policyDocument.Statement = append(policyDocument.Statement, t.Spec.ClusterAPIControllers.TrustStatements...)
return policyDocument
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (t Template) controlPlanePolicies() []cfn_iam.Role_Policy {
}

func (t Template) controlPlaneTrustPolicy() *iamv1.PolicyDocument {
policyDocument := ec2AssumeRolePolicy()
policyDocument := ec2AssumeRolePolicy(false)
policyDocument.Statement = append(policyDocument.Statement, t.Spec.ControlPlane.TrustStatements...)
return policyDocument
}
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ Resources:
Statement:
- Action:
- sts:AssumeRole
- sts:TagSession
Effect: Allow
Principal:
Service:
Expand Down Expand Up @@ -464,6 +465,7 @@ Resources:
Principal:
Service:
- ec2.amazonaws.com
- pods.eks.amazonaws.com
Version: 2012-10-17
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ Resources:
Statement:
- Action:
- sts:AssumeRole
- sts:TagSession
Effect: Allow
Principal:
Service:
Expand All @@ -436,6 +437,7 @@ Resources:
Principal:
Service:
- ec2.amazonaws.com
- pods.eks.amazonaws.com
Version: 2012-10-17
RoleName: controllers.cluster-api-provider-aws.sigs.k8s.io
Type: AWS::IAM::Role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ Resources:
Statement:
- Action:
- sts:AssumeRole
- sts:TagSession
Effect: Allow
Principal:
Service:
Expand All @@ -449,6 +450,7 @@ Resources:
Principal:
Service:
- ec2.amazonaws.com
- pods.eks.amazonaws.com
Version: 2012-10-17
RoleName: controllers.cluster-api-provider-aws.sigs.k8s.io
Type: AWS::IAM::Role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ Resources:
Statement:
- Action:
- sts:AssumeRole
- sts:TagSession
Effect: Allow
Principal:
Service:
Expand All @@ -441,6 +442,7 @@ Resources:
Principal:
Service:
- ec2.amazonaws.com
- pods.eks.amazonaws.com
Version: 2012-10-17
RoleName: controllers.cluster-api-provider-aws.sigs.k8s.io
Type: AWS::IAM::Role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ Resources:
Statement:
- Action:
- sts:AssumeRole
- sts:TagSession
Effect: Allow
Principal:
Service:
Expand All @@ -444,6 +445,7 @@ Resources:
Principal:
Service:
- ec2.amazonaws.com
- pods.eks.amazonaws.com
Version: 2012-10-17
RoleName: controllers.cluster-api-provider-aws.sigs.k8s.io
Type: AWS::IAM::Role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ Resources:
Statement:
- Action:
- sts:AssumeRole
- sts:TagSession
Effect: Allow
Principal:
Service:
Expand All @@ -444,6 +445,7 @@ Resources:
Principal:
Service:
- ec2.amazonaws.com
- pods.eks.amazonaws.com
Version: 2012-10-17
RoleName: controllers.cluster-api-provider-aws.sigs.k8s.io
Type: AWS::IAM::Role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ Resources:
Statement:
- Action:
- sts:AssumeRole
- sts:TagSession
Effect: Allow
Principal:
Service:
Expand All @@ -436,6 +437,7 @@ Resources:
Principal:
Service:
- ec2.amazonaws.com
- pods.eks.amazonaws.com
Version: 2012-10-17
RoleName: controllers.cluster-api-provider-aws.sigs.k8s.io
Type: AWS::IAM::Role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ Resources:
Statement:
- Action:
- sts:AssumeRole
- sts:TagSession
Effect: Allow
Principal:
Service:
Expand All @@ -456,6 +457,7 @@ Resources:
Principal:
Service:
- ec2.amazonaws.com
- pods.eks.amazonaws.com
Version: 2012-10-17
RoleName: controllers.cluster-api-provider-aws.sigs.k8s.io
Type: AWS::IAM::Role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ Resources:
Statement:
- Action:
- sts:AssumeRole
- sts:TagSession
Effect: Allow
Principal:
Service:
Expand All @@ -435,7 +436,8 @@ Resources:
Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
- ec2.amazonaws.com
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm there's a trailing space added here for some reason

- pods.eks.amazonaws.com
Version: 2012-10-17
RoleName: controllers.cluster-api-provider-aws.sigs.k8s.io
Type: AWS::IAM::Role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ Resources:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
- sts:AssumeRole
- sts:TagSession
Effect: Allow
Principal:
Service:
Expand All @@ -436,6 +437,7 @@ Resources:
Principal:
Service:
- ec2.amazonaws.com
- pods.eks.amazonaws.com
Version: 2012-10-17
RoleName: controllers.cluster-api-provider-aws.sigs.k8s.io
Type: AWS::IAM::Role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ Resources:
Statement:
- Action:
- sts:AssumeRole
- sts:TagSession
Effect: Allow
Principal:
Service:
Expand Down Expand Up @@ -454,6 +455,7 @@ Resources:
Principal:
Service:
- ec2.amazonaws.com
- pods.eks.amazonaws.com
Version: 2012-10-17
Policies:
- PolicyDocument:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ Resources:
Statement:
- Action:
- sts:AssumeRole
- sts:TagSession
Effect: Allow
Principal:
Service:
Expand All @@ -449,6 +450,7 @@ Resources:
Principal:
Service:
- ec2.amazonaws.com
- pods.eks.amazonaws.com
Version: 2012-10-17
RoleName: controllers.cluster-api-provider-aws.sigs.k8s.io
Type: AWS::IAM::Role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ Resources:
Statement:
- Action:
- sts:AssumeRole
- sts:TagSession
Effect: Allow
Principal:
Service:
Expand All @@ -436,6 +437,7 @@ Resources:
Principal:
Service:
- ec2.amazonaws.com
- pods.eks.amazonaws.com
Version: 2012-10-17
RoleName: controllers.cluster-api-provider-aws.sigs.k8s.io
Type: AWS::IAM::Role
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterawsadm/cloudformation/bootstrap/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (t Template) nodePolicies() []cfn_iam.Role_Policy {
}

func (t Template) nodeTrustPolicy() *iamv1.PolicyDocument {
policyDocument := ec2AssumeRolePolicy()
policyDocument := ec2AssumeRolePolicy(false)
policyDocument.Statement = append(policyDocument.Statement, t.Spec.Nodes.TrustStatements...)
return policyDocument
}
10 changes: 7 additions & 3 deletions cmd/clusterawsadm/cloudformation/bootstrap/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (t Template) RenderCloudFormation() *cloudformation.Template {
template.Resources[AWSIAMRoleControllers] = &cfn_iam.Role{
RoleName: t.NewManagedName("controllers"),
Path: t.Spec.ControlPlane.Path,
AssumeRolePolicyDocument: t.controllersTrustPolicy(),
AssumeRolePolicyDocument: t.controllersTrustPolicy(!t.Spec.EKS.Disable),
Policies: t.controllersRolePolicy(),
PermissionsBoundary: t.Spec.ControlPlane.PermissionsBoundary,
Tags: converters.MapToCloudFormationTags(t.Spec.ClusterAPIControllers.Tags),
Expand Down Expand Up @@ -224,8 +224,12 @@ func (t Template) RenderCloudFormation() *cloudformation.Template {
return template
}

func ec2AssumeRolePolicy() *iamv1.PolicyDocument {
return AssumeRolePolicy(iamv1.PrincipalService, []string{"ec2.amazonaws.com"})
func ec2AssumeRolePolicy(eksEnabled bool) *iamv1.PolicyDocument {
principalIDs := []string{"ec2.amazonaws.com"}
if eksEnabled {
principalIDs = append(principalIDs, "pods.eks.amazonaws.com")
}
return AssumeRolePolicy(iamv1.PrincipalService, principalIDs)
}

// AWSArnAssumeRolePolicy will assume Policies using PolicyArns.
Expand Down
1 change: 1 addition & 0 deletions cmd/clusterawsadm/cmd/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func RootCmd() *cobra.Command {
newCmd.AddCommand(credentials.UpdateCredentialsCmd())
newCmd.AddCommand(credentials.PrintCredentialsCmd())
newCmd.AddCommand(rollout.RolloutControllersCmd())
newCmd.AddCommand(credentials.UseEKSPodIdentityCmd())

return newCmd
}
Loading
Loading