From ab105303743192f6457eef9b0838a280f79ec135 Mon Sep 17 00:00:00 2001 From: Michael Kaylan <1063516+kaylanm@users.noreply.github.com> Date: Sat, 23 Oct 2021 15:04:32 -0400 Subject: [PATCH] feat(eks): expose FargateCluster's defaultProfile --- packages/@aws-cdk/aws-eks/README.md | 2 ++ packages/@aws-cdk/aws-eks/lib/fargate-cluster.ts | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-eks/README.md b/packages/@aws-cdk/aws-eks/README.md index 3b04f5d9e7f61..cd6e324ecf788 100644 --- a/packages/@aws-cdk/aws-eks/README.md +++ b/packages/@aws-cdk/aws-eks/README.md @@ -342,6 +342,8 @@ const cluster = new eks.FargateCluster(this, 'MyCluster', { }); ``` +`FargateCluster` will create a default `FargateProfile` which can be accessed via the cluster's `defaultProfile` property. The created profile can also be customized by passing options as with `addFargateProfile`. + **NOTE**: Classic Load Balancers and Network Load Balancers are not supported on pods running on Fargate. For ingress, we recommend that you use the [ALB Ingress Controller](https://docs.aws.amazon.com/eks/latest/userguide/alb-ingress.html) diff --git a/packages/@aws-cdk/aws-eks/lib/fargate-cluster.ts b/packages/@aws-cdk/aws-eks/lib/fargate-cluster.ts index 11036875a9d30..022d6bc6ecdbf 100644 --- a/packages/@aws-cdk/aws-eks/lib/fargate-cluster.ts +++ b/packages/@aws-cdk/aws-eks/lib/fargate-cluster.ts @@ -1,6 +1,6 @@ import { Construct } from 'constructs'; import { Cluster, ClusterOptions, CoreDnsComputeType } from './cluster'; -import { FargateProfileOptions } from './fargate-profile'; +import { FargateProfile, FargateProfileOptions } from './fargate-profile'; /** * Configuration props for EKS Fargate. @@ -23,6 +23,11 @@ export interface FargateClusterProps extends ClusterOptions { * `addFargateProfile`. */ export class FargateCluster extends Cluster { + /** + * Fargate Profile that was created with the cluster. + */ + public readonly defaultProfile: FargateProfile; + constructor(scope: Construct, id: string, props: FargateClusterProps) { super(scope, id, { ...props, @@ -31,7 +36,7 @@ export class FargateCluster extends Cluster { version: props.version, }); - this.addFargateProfile( + this.defaultProfile = this.addFargateProfile( props.defaultProfile?.fargateProfileName ?? (props.defaultProfile ? 'custom' : 'default'), props.defaultProfile ?? { selectors: [