Skip to content

Commit bbd2234

Browse files
committed
Allow for private interface endpoint
Signed-off-by: Connor Avery <[email protected]>
1 parent 7fe6ed1 commit bbd2234

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/cdk/stacks/VpcResourcesStack.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export class VpcResourcesStack extends Stack {
108108
this.addInterfaceEndpoint("CloudWatchEventsEndpoint", InterfaceVpcEndpointAwsService.EVENTBRIDGE)
109109
this.addInterfaceEndpoint("SSMEndpoint", InterfaceVpcEndpointAwsService.SSM)
110110
this.addInterfaceEndpoint("LambdaEndpoint", InterfaceVpcEndpointAwsService.LAMBDA)
111-
this.addInterfaceEndpoint("apiGatewayEndpoint", InterfaceVpcEndpointAwsService.APIGATEWAY)
111+
this.addPrivateInterfaceEndpoint("apiGatewayEndpoint", InterfaceVpcEndpointAwsService.APIGATEWAY)
112112
this.addGatewayEndpoint("S3Endpoint", InterfaceVpcEndpointAwsService.S3)
113113

114114
//Outputs
@@ -162,6 +162,16 @@ export class VpcResourcesStack extends Stack {
162162
endpoint.connections.allowFrom(Peer.ipv4(this.vpc.vpcCidrBlock), endpoint.connections.defaultPort!)
163163
}
164164

165+
private addPrivateInterfaceEndpoint(name: string, awsService: InterfaceVpcEndpointAwsService): void {
166+
const endpoint: InterfaceVpcEndpoint = this.vpc.addInterfaceEndpoint(name, {
167+
service: awsService
168+
})
169+
this.addEndpointTag(name, endpoint)
170+
171+
endpoint.connections.allowFrom(Peer.ipv4(this.vpc.privateSubnets[0].ipv4CidrBlock),
172+
endpoint.connections.defaultPort!)
173+
}
174+
165175
private addGatewayEndpoint(name: string, awsService: InterfaceVpcEndpointAwsService): void {
166176
const endpoint: GatewayVpcEndpoint = this.vpc.addGatewayEndpoint(name, {
167177
service: awsService

0 commit comments

Comments
 (0)