Use environment variable aliases to connect services using Qovery’s built-in variables in Terraform
When one service needs to call another, Qovery automatically generates built-in variables exposing each service’s hostname. In Terraform, you expose those variables to a dependent service using environment_variable_aliases.
For example, if the application ID is a1b2c3d4-xxxx-xxxx-xxxx-xxxxxxxxxxxx, the built-in variable is:
QOVERY_APPLICATION_ZA1B2C3D4_HOST_INTERNAL
Use HOST_INTERNAL for service-to-service communication within the same cluster. Use HOST_EXTERNAL only when the consumer must reach the other service from outside the cluster.
The expression upper(element(split("-", qovery_application.backend.id), 0)) splits the UUID on -, takes the first segment, and uppercases it — matching the name Qovery generates for that service.
If you wrap qovery_application in a reusable Terraform module, expose the built-in variable name as an output. This avoids repeating the string manipulation everywhere the module is used.modules/application/outputs.tf
output "internal_host_envvar" { value = "QOVERY_APPLICATION_Z${upper(element(split("-", qovery_application.app.id), 0))}_HOST_INTERNAL" description = "Built-in variable name for this service's internal hostname"}output "external_host_envvar" { value = "QOVERY_APPLICATION_Z${upper(element(split("-", qovery_application.app.id), 0))}_HOST_EXTERNAL" description = "Built-in variable name for this service's external hostname"}