Skip to content

Commit

Permalink
make IAM roles trust the production EKS Service Principal
Browse files Browse the repository at this point in the history
  • Loading branch information
TiberiuGC committed Nov 27, 2023
1 parent 9fbbcfd commit cc6a35a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"bytes"
"context"
"encoding/json"
"fmt"
"testing"

"github.com/aws/aws-sdk-go-v2/aws"
Expand Down Expand Up @@ -420,14 +421,14 @@ var (
return cfg
}

trustPolicy = aws.String(`{
trustPolicy = aws.String(fmt.Sprintf(`{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"beta.pods.eks.aws.internal"
"%s"
]
},
"Action": [
Expand All @@ -436,7 +437,7 @@ var (
]
}
]
}`)
}`, api.EKSServicePrincipal))

permissionPolicy = api.InlineDocument{
"Version": "2012-10-17",
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/eksctl.io/v1alpha5/iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
// Commonly-used constants
const (
AnnotationEKSRoleARN = "eks.amazonaws.com/role-arn"
EKSServicePrincipal = "pods.eks.amazonaws.com"
)

// ClusterIAM holds all IAM attributes of a cluster
Expand Down
7 changes: 5 additions & 2 deletions pkg/cfn/template/iam_helpers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package template

import gfn "github.com/weaveworks/goformation/v4/cloudformation/types"
import (
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
gfn "github.com/weaveworks/goformation/v4/cloudformation/types"
)

// AttachPolicy attaches the specified policy document
func (t *Template) AttachPolicy(name string, refRole *Value, policyDoc MapOfInterfaces) {
Expand Down Expand Up @@ -63,7 +66,7 @@ func MakeAssumeRolePolicyDocumentForPodIdentity() MapOfInterfaces {
"sts:TagSession",
},
"Principal": map[string]string{
"Service": "beta.pods.eks.aws.internal",
"Service": api.EKSServicePrincipal,
},
})
}

0 comments on commit cc6a35a

Please sign in to comment.