Closed kkzhao63 closed 3 years ago
You need to specify SubnetSelection[]
, aka an array of SubnetSelection
. Currently, you are just supplying one SubnetSelection
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
:question: SubnetSelection not available to choose specific subnet in an existing VPC
The Question
When I am creating Elasticsearch domain using AWS CDK, I cannot specify vpc subnets. According to DomainProps interface document (https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-elasticsearch.DomainProps.html ), it has vpcSubnets property in which I should be able to specify SubnetSeletion (https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-ec2.SubnetSelection.html ) with subnetType and availabilityZones with something like:
However, I always got the following error message:
===== error message begins ====== cdk synth vxCabinetElasticSearch ⨯ Unable to compile TypeScript: lib/elasticsearch-stack.ts:38:10 - error TS2322: Type '{ subnetType: ec2.SubnetType.PRIVATE; availabilityZones: string[]; }' is not assignable to type 'SubnetSelection[]'. Object literal may only specify known properties, and 'subnetType' does not exist in type 'SubnetSelection[]'.
38 subnetType: ec2.SubnetType.PRIVATE,
Subprocess exited with error 1 ezhao@ESDD-65284L:~/CDK/e-cabinet-app-infrastructure$ ===== error message ends ======
Environment
Other information
import as cdk from '@aws-cdk/core'; import as es from '@aws-cdk/aws-elasticsearch'; import * as ec2 from '@aws-cdk/aws-ec2'; import { IEnvironmentConfig } from '../config/environment-config'; import { EnvironmentConfig } from '../config/environment-config';
const appConfig = EnvironmentConfig.predevEnvConfig
export interface CustomStackProps extends cdk.StackProps { envConfig: IEnvironmentConfig, } export class vxCabinetElasticSearchStack extends cdk.Stack{ constructor(scope: cdk.Construct, id: string, props: CustomStackProps) { super(scope, id, props);
} }