From 66af3013ea99b54d61c8131a819b7174b58b774e Mon Sep 17 00:00:00 2001 From: maz Date: Sun, 22 Dec 2024 15:34:18 +0900 Subject: [PATCH] add ip address type --- .../integ.vpc-endpoint-ip-address-type.ts | 28 ++++++++++++++++ .../aws-cdk-lib/aws-ec2/lib/vpc-endpoint.ts | 33 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.vpc-endpoint-ip-address-type.ts diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.vpc-endpoint-ip-address-type.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.vpc-endpoint-ip-address-type.ts new file mode 100644 index 0000000000000..a6f7fecd5380a --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.vpc-endpoint-ip-address-type.ts @@ -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], +}); diff --git a/packages/aws-cdk-lib/aws-ec2/lib/vpc-endpoint.ts b/packages/aws-cdk-lib/aws-ec2/lib/vpc-endpoint.ts index 58f46b4f3dc67..b0a0fea14c651 100644 --- a/packages/aws-cdk-lib/aws-ec2/lib/vpc-endpoint.ts +++ b/packages/aws-cdk-lib/aws-ec2/lib/vpc-endpoint.ts @@ -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' } /** @@ -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;