Hello terraform question here, I recently discovered that to set up Firebase as Identity Source for my HTTP. Gateway I need to use aws_gatewayv2_*
resources on terraform.
I don’t understand how to set this properly up now as all tutorials / articles I’ve read seem to be incomplete or not correct (?) because they create an own aws_apigatewayv2_api
resource for each endpoint. If I understood correctly then you should have one main aws_apigatewayv2_api
resource and then each endpoint should be a aws_apigatewayv2_route
and point to a aws_apigatewayv2_api
.
I keep getting error creating API Gateway v2 route: BadRequestException: Unexpected or malformed target in route null. Correct format should be integrations/<integration_id>.
But I don’t really understandwhy nor do I see any issue
resource "aws_apigatewayv2_integration" "auth_integration" {
api_id = aws_apigatewayv2_api.loremio_gw_2.id
description = "Lambda Serverless Upstream Service"
passthrough_behavior = "WHEN_NO_MATCH"
payload_format_version = "2.0"
# Upstream
integration_type = "AWS_PROXY"
integration_uri = aws_lambda_function.loremio_auth_lambda.invoke_arn
connection_type = "INTERNET"
integration_method = "POST"
timeout_milliseconds = 29000
lifecycle {
ignore_changes = [
passthrough_behavior
]
}
}
# the authorizer
resource "aws_apigatewayv2_authorizer" "firebase_authorizer" {
name = "firebase_authorizer"
identity_sources = ["$request.header.Authorization"]
jwt_configuration {
issuer = "[https://securetoken.google.com/myproject-b3439](https://securetoken.google.com/myproject-b3439)"
audience = ["myproject-b3439"]
}
authorizer_type = "JWT"
api_id = aws_apigatewayv2_api.loremio_gw_2.id
}
# the route
resource "aws_apigatewayv2_route" "auth_route" {
api_id = aws_apigatewayv2_api.loremio_gw_2.id
route_key = "GET /auth"
target = "integrations/${aws_apigatewayv2_integration.auth_integration.api_id}"
# Authorization
authorizer_id = aws_apigatewayv2_authorizer.firebase_authorizer.id
}
# main api
resource "aws_apigatewayv2_api" "loremio_gw_2" {
name = "loremio api gateway v2"
protocol_type = "HTTP"
}```