Terraform - passing output of other resources during execution
Last Updated:
Overview
The customer needs to create a client grant with information that is obtained from during the same deployment, in this case the client_id of a client application that is created on the same run
resource "auth0_client_grant" "my_client_grant" {
client_id = "<client_id>"
audience = "<audience>"
scope = []
}
Symptoms
If they don't pass the clientID hardcoded, the run fails as they don't know how to pass it
Applies To
- Terraform
Cause
Solution
"auth0_client" "my_client" {
//your code for this client
}
you can call a specific value obtained during execution in the following way:
<rousource_provider>.<resource_name>.<TheRequiredAttribute>In this case, it would be something similar to this:
auth0_client.my_client.client_id
However, it would be a good practice to suggest the customer to look at both Terraform Outputs, and Terraform Modules so their terraform implementation could be easy to maintain and reuse in the future (having said that, that falls into Hashicorp's scope rather than Auth0 product configuration.
Outputs: https://www.terraform.io/language/values/outputs
Modules: https://www.terraform.io/language/modules/syntax