I have two .tf files in my root module:
the first one is called api-gateway.tf which provision an API Gateway in AWS:
resource "aws_apigatewayv2_api" "apiGateway" {
name = "some_Name"
protocol_type = "HTTP"
}
output "api_gateway_endpoint" {
value = "${aws_apigatewayv2_api.apiGateway.api_endpoint}"
}
output "api_gateway_endpoint_id" {
value = "${aws_apigatewayv2_api.apiGateway.id}"
}
I have got another .tf file called route53.tf which creates a Route53 record :
resource "aws_route53_record" "www" {
zone_id = "xxxxx"
name = "someurl.com"
type = "A"
alias {
name = "${output.api_gateway_endpoint}"
zone_id = "${output.api_gateway_endpoint_id}"
evaluate_target_health = false
}
}
I need to pass the api_endpoint and id of the apigateway to route53, but I don't know how?
I have tried returning these two values using output and reference that inside the route53 resource, however it doesn't work. It gives me an undeclared resource error.
How do you assign the output value of one resource as input to another?