From 41fdebb974a2b29ba461757d210fa3a8b8cdc73d Mon Sep 17 00:00:00 2001 From: Peter Woodworth <44349620+peterwoodworth@users.noreply.github.com> Date: Thu, 23 Sep 2021 13:55:47 -0700 Subject: [PATCH] feat(eks): add warning to fargateProfile (#16631) partially fixes #16349 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-eks/lib/fargate-profile.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-eks/lib/fargate-profile.ts b/packages/@aws-cdk/aws-eks/lib/fargate-profile.ts index 4ce6f094909bd..d998e7ec77b76 100644 --- a/packages/@aws-cdk/aws-eks/lib/fargate-profile.ts +++ b/packages/@aws-cdk/aws-eks/lib/fargate-profile.ts @@ -1,6 +1,6 @@ import * as ec2 from '@aws-cdk/aws-ec2'; import * as iam from '@aws-cdk/aws-iam'; -import { CustomResource, ITaggable, Lazy, TagManager, TagType } from '@aws-cdk/core'; +import { Annotations, CustomResource, ITaggable, Lazy, TagManager, TagType } from '@aws-cdk/core'; import { Construct } from 'constructs'; import { Cluster } from './cluster'; import { FARGATE_PROFILE_RESOURCE_TYPE } from './cluster-resource-handler/consts'; @@ -156,6 +156,10 @@ export class FargateProfile extends CoreConstruct implements ITaggable { this.podExecutionRole.grantPassRole(props.cluster.adminRole); + if (props.subnetSelection && !props.vpc) { + Annotations.of(this).addWarning('Vpc must be defined to use a custom subnet selection. All private subnets belonging to the EKS cluster will be used by default'); + } + let subnets: string[] | undefined; if (props.vpc) { const selection: ec2.SubnetSelection = props.subnetSelection ?? { subnetType: ec2.SubnetType.PRIVATE };