aws-quickstart / cdk-eks-blueprints

AWS Quick Start Team
Apache License 2.0
460 stars 206 forks source link

Issue: Unable to Attach podExecutionRole to Fargate Profile Using Blueprint #1069

Closed saiumesh-appfire closed 3 months ago

saiumesh-appfire commented 3 months ago

Hello There!!

I’m facing an issue where I cannot attach a podExecutionRole to a Fargate profile because the Blueprint doesn’t allow using the existing stack. This limitation is causing problems in setting up the necessary role for my Fargate profiles.

Example code as follow

new FargateClusterProvider({
    version: KubernetesVersion.V1_29,
    clusterName: `${this.props.clusterName}`,
    fargateProfiles: this.getFargateProfiles(),
    tags: this.props.tags,
});

private getFargateProfiles(): Map<string, FargateProfileOptions> {
    const namespaces = [
        ...this.props.namespaces.map((namespace) => namespace.name),
    ];

    // Issue: How do we correctly obtain the scope here?
    const role = new Role(this.scope, "FargatePodExecutionRole", {});

    return new Map([
        // Observability
        [
            "observability",
            {
                selectors: OBSERVABILITY_NAMESPACES.map((namespace) => ({
                    namespace,
                })),
                podExecutionRole: role,
            },
        ],
    ]);
}

Problem:

The Blueprint setup doesn’t provide a clear way to reference an existing stack’s scope, which is necessary to create and attach the podExecutionRole to a Fargate profile.

Request:

I’m looking for guidance on how to correctly obtain the scope in this context, or if there’s an alternative approach to achieve this.

Links

https://aws-quickstart.github.io/cdk-eks-blueprints/cluster-providers/fargate-cluster-provider/