AWS API Gateway V2 VPC Link

This page shows how to write Terraform and CloudFormation for API Gateway V2 VPC Link and write them securely.

aws_apigatewayv2_vpc_link (Terraform)

The VPC Link in API Gateway V2 can be configured in Terraform with the resource name aws_apigatewayv2_vpc_link. The following sections describe 4 examples of how to use the resource and its parameters.

Example Usage from GitHub

vpc_link.tf#L1
resource "aws_apigatewayv2_vpc_link" "main" {
  name = "alb-private-link"
  security_group_ids = [var.vpc_link_sg_ids]
  subnet_ids = var.private_subnets
vpclink.tf#L1
resource "aws_apigatewayv2_vpc_link" "vpilink" {
  name               = var.vpc_link_name
  security_group_ids = [aws_security_group.vpclink.id]
  subnet_ids         = var.subnet_private_ids

  tags = {
main.tf#L7
resource "aws_apigatewayv2_vpc_link" "this" {
  name               = var.name
  security_group_ids = var.security_group_ids
  subnet_ids         = var.subnet_ids
  tags               = var.tags
}
gateway.tf#L24
resource "aws_apigatewayv2_vpc_link" "vpclink" {
  name               = "neocar_vpclink"
  security_group_ids = [var.LBSecurityGroup]
  subnet_ids         = var.VPCSubnets
}

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages an Amazon API Gateway Version 2 VPC Link. -> Note: Amazon API Gateway Version 2 VPC Links enable private integrations that connect HTTP APIs to private resources in a VPC. To enable private integration for REST APIs, use the Amazon API Gateway Version 1 VPC Link resource.

AWS::ApiGatewayV2::VpcLink (CloudFormation)

The VpcLink in ApiGatewayV2 can be configured in CloudFormation with the resource name AWS::ApiGatewayV2::VpcLink. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

An example could not be found in GitHub.

Parameters

Explanation in CloudFormation Registry

The AWS::ApiGatewayV2::VpcLink resource creates a VPC link. Supported only for HTTP APIs. The VPC link status must transition from PENDING to AVAILABLE to successfully create a VPC link, which can take up to 10 minutes. To learn more, see Working with VPC Links for HTTP APIs in the API Gateway Developer Guide.

Frequently asked questions

AWS API Gateway V2 VPC Link is a resource for API Gateway V2 of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

For Terraform, the Piroddi/aws-http-api-private-alb, nekochans/kimono-app-terraform and niveklabs/aws source code examples are useful. See the Terraform Example section for further details.