如何 link "aws_apigatewayv2_route" 与 "aws_apigatewayv2_integration"?

How to link "aws_apigatewayv2_route" with "aws_apigatewayv2_integration"?

我正在使用 HTTP 协议类型使用 terraform 为 Amazon API 网关版本 2 创建一个 terraform 脚本。我无法弄清楚如何 link 集成网关路由。我曾尝试在“aws_apigatewayv2_route”中使用“目标”属性,但它不起作用。下面是我为它编写的代码。

resource "aws_apigatewayv2_api" "mrw-api" {
  name          = "mrw-http-api"
  protocol_type = "HTTP"
}

resource "aws_apigatewayv2_vpc_link" "mrw-link" {
  name               = "mrw-link"
  security_group_ids = [data.aws_security_group.mrw-sg.id]
  subnet_ids         = [data.aws_subnet.mrw-subnet.id, data.aws_subnet.mrw-subnet2.id]

}

resource "aws_apigatewayv2_route" "healthcheck" {
  api_id    = aws_apigatewayv2_api.mrw-api.id
  route_key = "GET /"
  target    = aws_apigatewayv2_integration.mrw-int-get.id
}

resource "aws_apigatewayv2_integration" "mrw-int-get" {
  api_id             = aws_apigatewayv2_api.mrw-api.id
  integration_type   = "HTTP_PROXY"
  connection_type    = "VPC_LINK"
  connection_id      = aws_apigatewayv2_vpc_link.mrw-link.id
  integration_uri    = aws_lb_listener.mrw-lb-listener.arn
  integration_method = "GET"
  tls_config {
    server_name_to_verify = var.tls_server_name
  }
}

任何人都可以帮助 link 集成路线。

Terraform 对此的文档不​​是很清楚。 target 的格式是 integrations/integration-id。在你的情况下,使用 "integrations/${aws_apigatewayv2_integration.mrw-int-get.id}"