Asking another question from my previous post found here
In my development I have simplified CloudRun and CloudEndpoint from child module to root module as so >
-dir
- main.tf
- modules
- services
- CloudRun
- CloudEndpoints
I have main config provisioning CloudRun and CloudEndpoints modules. I'm able to create CloudRun and CloudRun . Now the fun part, I've output the url and url minus prefix of api-gateway url after provisioning the deployment. Then, I need to go into the CloudEndpoints > openapi_spec.yml to edit the host = api.gateway.url (without the https) and address to the CloudRun application url. I want to know how I can pass in the output from root dir (main.tf config) to child module as an variable for template_file?
# ------------------------------------------------------------------------------
# GCP ENDPOINT service test
# ------------------------------------------------------------------------------
data "template_file" "openapi_spec" {
template = file("${path.module}/openapi_spec.yml", { CloudRunESPURL2= module.CloudRunESP2.urlesp , CloudStorageURL2= module.helloapp.url })
}
resource "google_endpoints_service" "api-service" {
service_name = "api.endpoints.project.cloud.goog"
project = var.project
openapi_config = data.template_file.openapi_spec.rendered
}
CloudRunESPURL2= module.CloudRunESP2.urlesp , CloudStorageURL2= module.helloapp.url
The variables values that are passed in are the output of the variables being passed from child module to root module then back to child module.
I'm looking to simplify this step as one provisioned configuration.