Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions packages/@aws-cdk/aws-apigatewayv2/lib/http/vpc-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface VpcLinkProps {
*
* @default - private subnets of the provided VPC. Use `addSubnets` to add more subnets
*/
readonly subnets?: ec2.ISubnet[];
readonly subnets?: ec2.SubnetSelection;

/**
* A list of security groups for the VPC link.
Expand Down Expand Up @@ -99,11 +99,8 @@ export class VpcLink extends Resource implements IVpcLink {

this.vpcLinkId = cfnResource.ref;

this.addSubnets(...props.vpc.privateSubnets);

if (props.subnets) {
this.addSubnets(...props.subnets);
}
const { subnets } = props.vpc.selectSubnets(props.subnets ?? { subnetType: ec2.SubnetType.PRIVATE });
this.addSubnets(...subnets);

if (props.securityGroups) {
this.addSecurityGroups(...props.securityGroups);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,14 @@ describe('VpcLink', () => {
// WHEN
new VpcLink(stack, 'VpcLink', {
vpc,
subnets: [subnet1, subnet2],
subnets: { subnets: [subnet1, subnet2] },
securityGroups: [sg1, sg2, sg3],
});

// THEN
expect(stack).toHaveResource('AWS::ApiGatewayV2::VpcLink', {
Name: 'VpcLink',
SubnetIds: [
{
Ref: 'VPCPrivateSubnet1Subnet8BCA10E0',
},
{
Ref: 'VPCPrivateSubnet2SubnetCFCDAA7A',
},
{
Ref: 'subnet1Subnet16A4B3BD',
},
Expand Down