Skip to content

Commit bc04686

Browse files
committed
feat: add Fargate profile support for beta endpoint
1 parent a11df6a commit bc04686

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

pkg/cfn/builder/beta.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,17 @@ func addBetaAccessEntry(stackName string, accessEntryType string) *gfn.CustomRes
251251
customResource.Properties["Type"] = gfnt.NewString(accessEntryType)
252252
return customResource
253253
}
254+
255+
func createBetaFargateAssumeRolePolicy(sourceArnCondition cft.MapOfInterfaces) interface{} {
256+
statements := []cft.MapOfInterfaces{
257+
{
258+
"Effect": "Allow",
259+
"Principal": cft.MapOfInterfaces{
260+
"Service": "eks-fargate-pods.aws.internal",
261+
},
262+
"Action": "sts:AssumeRole",
263+
"Condition": sourceArnCondition,
264+
},
265+
}
266+
return cft.MakePolicyDocument(statements...)
267+
}

pkg/cfn/builder/fargate.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,19 @@ func addResourcesForFargate(rs *resourceSet, cfg *api.ClusterConfig) error {
8484
return fmt.Errorf("restricting access based on SourceArn: %w", err)
8585
}
8686

87-
role := &gfniam.Role{
88-
AssumeRolePolicyDocument: cft.MakeAssumeRolePolicyDocumentForServicesWithConditions(
87+
var assumeRolePolicyDocument interface{}
88+
if cfg.IsCustomEksEndpoint() {
89+
// Use beta assume role policy for beta stacks with Fargate-specific service principals
90+
assumeRolePolicyDocument = createBetaFargateAssumeRolePolicy(sourceArnCondition)
91+
} else {
92+
assumeRolePolicyDocument = cft.MakeAssumeRolePolicyDocumentForServicesWithConditions(
8993
sourceArnCondition,
9094
MakeServiceRef("EKSFargatePods"), // Ensure that EKS can schedule pods onto Fargate.
91-
),
95+
)
96+
}
97+
98+
role := &gfniam.Role{
99+
AssumeRolePolicyDocument: assumeRolePolicyDocument,
92100
ManagedPolicyArns: gfnt.NewSlice(makePolicyARNs(
93101
iamPolicyAmazonEKSFargatePodExecutionRolePolicy,
94102
)...),

0 commit comments

Comments
 (0)