private renderVpc()

in packages/cdk/lib/stacks/core-stack.ts [89:132]


  private renderVpc(vpcId?: string): IVpc {
    if (vpcId) {
      return Vpc.fromLookup(this, "Vpc", { vpcId });
    }
    const vpc = new Vpc(this, "Vpc", {
      gatewayEndpoints: {
        S3Endpoint: { service: GatewayVpcEndpointAwsService.S3 },
      },
    });

    const subnetSelection = { subnets: vpc.privateSubnets, onePerAz: true };
    vpc.addInterfaceEndpoint(`${PRODUCT_NAME}LogsEndpoint`, {
      service: new InterfaceVpcEndpointService(`com.amazonaws.${this.region}.logs`),
      subnets: subnetSelection,
      open: true,
    });
    vpc.addInterfaceEndpoint(`${PRODUCT_NAME}EcrDkrEndpoint`, {
      service: new InterfaceVpcEndpointService(`com.amazonaws.${this.region}.ecr.dkr`),
      subnets: subnetSelection,
      open: true,
    });
    vpc.addInterfaceEndpoint(`${PRODUCT_NAME}EcrApiEndpoint`, {
      service: new InterfaceVpcEndpointService(`com.amazonaws.${this.region}.ecr.api`),
      subnets: subnetSelection,
      open: true,
    });
    vpc.addInterfaceEndpoint(`${PRODUCT_NAME}EcsAgentEndpoint`, {
      service: new InterfaceVpcEndpointService(`com.amazonaws.${this.region}.ecs-agent`),
      subnets: subnetSelection,
      open: true,
    });
    vpc.addInterfaceEndpoint(`${PRODUCT_NAME}EcsTelemEndpoint`, {
      service: new InterfaceVpcEndpointService(`com.amazonaws.${this.region}.ecs-telemetry`),
      subnets: subnetSelection,
      open: true,
    });
    vpc.addInterfaceEndpoint(`${PRODUCT_NAME}EcsEndpoint`, {
      service: new InterfaceVpcEndpointService(`com.amazonaws.${this.region}.ecs`),
      subnets: subnetSelection,
      open: true,
    });

    return vpc;
  }