Reputation: 2816
I have defined an azurerm_resource_group_template_deployment my_rm which has ARM template source:
{
...
"parameters": {... },
"resources": [ ... ],
"outputs": {
"db_name": {
"type": "string",
"value": "test_value"
}
}
}
I would like to use this output in terraform, like:
output "db_name" {
value = azurerm_resource_group_template_deployment.my_rm.output_content["db_name"]
}
Unfortunately above definition returns empty value.
What is the correct way to define the output in terraform?
Upvotes: 3
Views: 1462
Reputation: 28204
The output_content exports the JSON Content of the Outputs of the ARM Template Deployment.
After my validation, you could output the content with
output "db_name" {
value = azurerm_resource_group_template_deployment.my_rm.output_content
}
Then run terraform apply
, you will see the output result, then you can change to filter the result with
output "db_name" {
value = jsondecode(azurerm_resource_group_template_deployment.my_rm.output_content).db_name.value
}
Please note that the db_name
is not the same declaration db_name
in your terraform code, it really should match the output JSON key in the first above step.
For example,
Upvotes: 4