Select your cookie preferences

We use cookies and similar tools to enhance your experience, provide our services, deliver relevant advertising, and make improvements. Approved third parties also use these tools to help us deliver advertising and provide certain site features.

Loading...

Interface VPC Endpoint with Private IP

This is a CDK construct that retrieves the private IP address of an Interface VPC Endpoint:

View on Construct Hub Open in Visual Studio Code npm version Build Status Release Status License npm downloads

Architecture

Architecture

Installation

npm install cdk-vpc-endpoint-with-private-ip

Usage

You can create an interface VPC endpoint and retrive its private IP addresses using the VpcEndpointWithPrivateIp construct.

The ec2.InterfaceVpcEndpointProps can be passed to the construct to configure the interface VPC endpoint.

import { InterfaceVpcEndpointWithPrivateIp } from 'cdk-vpc-endpoint-with-private-ip';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
declare const vpc: ec2.IVpc;
const endpoint = new InterfaceVpcEndpointWithPrivateIp(this, 'Endpoint', {
vpc,
service: ec2.InterfaceVpcEndpointAwsService.S3,
});
const privateIps = endpoint.privateIps;

Note: privateIps is an array of CDK Tokens, and the actual IP addresses are not determined until the stack is deployed.

Special Thanks

I am greatly referencing the content of this post .