VPC Link with Application Load Balancer in Terraform?

0

According to "Working with VPC links for HTTP APIs":

**VPC links **enable you to create private integrations that connect your HTTP API routes to private resources in a VPC, such as Application Load Balancers or Amazon ECS container-based applications.

But:

resource "aws_api_gateway_vpc_link" "example_vpc_link" {
  name        = "example_vpc_link"
  target_arns = [aws_lb.example_lb.arn]
}
resource "aws_lb" "example_lb" {
  name               = "example-lb"
  internal           = true
  load_balancer_type = "application"
  security_groups    = [aws_security_group.example_sg.id]
  subnets            = local.subnet_ids
}

Gives me the error:

│ Error: creating API Gateway VPC Link (example_vpc_link): waiting for completion: FAILED: NLB ARN is malformed
│ 
│   with aws_api_gateway_vpc_link.example_vpc_link,
│   on main.tf line 139, in resource "aws_api_gateway_vpc_link" "example_vpc_link":
│  139: resource "aws_api_gateway_vpc_link" "example_vpc_link" {
│ 
╵

as if aws_api_gateway_vpc_link definitely refers to an NLB not an ALB.


So I assume this is an incomplete set of options for aws_api_gateway_vpc_link in Terraform (no option for target_type = "application", and we would need to do a work-around with a custom Terraform resource?

1 Answer
1
Accepted Answer

This does look like a bug in Terraform. The Terraform AWS Provider GitHub Repository is typically really good about responding to bug reports. I have seen deployed fixes in apx 2 weeks from time I reported it.

profile picture
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions