How can I reference an existing VPC Endpoint in AWS CDK?

Viewed 3673

How can I lookup and reference an existing VPC Endpoint in my Stack so that I can pass it to API Gateway RestApi() for private API?

2 Answers

msshenke's answer returns Ivpc what I needed was vpc endpoint reference.

This is what I found

https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-ec2.InterfaceVpcEndpoint.html#static-from-wbr-interface-wbr-vpc-wbr-endpoint-wbr-attributesscope-id-attrs

Need to supply the existing vpce id and the security group.

const ivpc = Vpc.InterfaceVpcEndpoint.fromInterfaceVpcEndpointAttributes(this, "VPC", {
    port: 443,
    vpcEndpointId: "vpce-1234567890",
    securityGroups: ["https-sg"] // or whatever you are using
});
Related