Skip to content

Commit

Permalink
add ip address type
Browse files Browse the repository at this point in the history
  • Loading branch information
mazyu36 committed Dec 22, 2024
1 parent 0546ec2 commit 66af301
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { App, Stack } from 'aws-cdk-lib/core';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import { IntegTest } from '@aws-cdk/integ-tests-alpha';

const app = new App();
const stack = new Stack(app, 'VpcEndpointIpAddressTypeStack');

const vpc = new ec2.Vpc(stack, 'DualStackVpc', {
ipProtocol: ec2.IpProtocol.DUAL_STACK,
});

vpc.addInterfaceEndpoint('IPv4', {
privateDnsEnabled: false,
service: ec2.InterfaceVpcEndpointAwsService.BEDROCK,
subnets: { subnetType: ec2.SubnetType.PUBLIC },
ipAddressType:ec2.IpAddressType.IPV4,
});

vpc.addInterfaceEndpoint('IPv6', {
privateDnsEnabled: false,
service: ec2.InterfaceVpcEndpointAwsService.S3_TABLES,
subnets: { subnetType: ec2.SubnetType.PUBLIC },
ipAddressType:ec2.IpAddressType.IPV6,
});

new IntegTest(app, 'VpcEndpointIpAddressTypeTest', {
testCases: [stack],
});
33 changes: 33 additions & 0 deletions packages/aws-cdk-lib/aws-ec2/lib/vpc-endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,38 @@ export interface InterfaceVpcEndpointOptions {
* @default false
*/
readonly lookupSupportedAzs?: boolean;

/**
* The supported IP address types.
*
* @default IpAddressType.IPV4
*/
readonly ipAddressType?: IpAddressType
}

/**
* The supported IP address types.
*/
export enum IpAddressType {
/**
* Use only IPv4 addresses
*/
IPV4 = 'ipv4',

/**
* Use only IPv6 addresses
*/
IPV6 = 'ipv6',

/**
* Use IPv4 and IPv6 addresses
*/
DUAL_STACK = 'dualstack',

/**
* not specified
*/
NOT_SPECIFIED = 'not-specified'
}

/**
Expand Down Expand Up @@ -892,6 +924,7 @@ export class InterfaceVpcEndpoint extends VpcEndpoint implements IInterfaceVpcEn
vpcEndpointType: VpcEndpointType.INTERFACE,
subnetIds,
vpcId: props.vpc.vpcId,
ipAddressType: props.ipAddressType,
});

this.vpcEndpointId = endpoint.ref;
Expand Down

0 comments on commit 66af301

Please sign in to comment.