问题描述
使用terraform和Azure ARM模板,为了使用特定的Azure函数配置事件网格,我试图在terraform输出中恢复一些值.
Using terraform and Azure ARM template, in order to configre event grid with a particular azure function, I am trying to recover some values in a terraform output.
实际上,我具有此ARm模板部署以具有特定功能的系统键:
Indeed, I have this ARm template deployment to have the systems keys of a particular function:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"functionApp": {
"type": "string",
"defaultValue": ""
}
},
"variables": {
"functionAppId": "[resourceId('Microsoft.Web/sites', parameters('functionApp'))]"
},
"resources": [],
"outputs": {
"systemKeys": {
"type": "object",
"value": "[listkeys(concat(variables('functionAppId'), '/host/default'), '2018-11-01').systemKeys]"
}
}
}
我的部署运行良好,因为我可以在Azure门户中看到输出中像这样的json对象:
My deployment working well, because I can see in Azure Portal that there are in output a json objecy like this:
{
"durabletask_extension": "ASensituveValueIDoNotShareForDurableTaskExtension==",
"eventgrid_extension": "ASensituveValueIDoNotShareForEventGridExtension=="
}
现在的目的是在terraform输出中获得此值之一.我尝试了这些,但出现了一些错误:
Now the purpose is to get one of this value in a terraform output.I tried these but I have got some errors:
output "syst_key" {
value = "${azurerm_template_deployment.function_keys.outputs["systemKeys"]}"
}
Error: on outputs.tf line 69, in output "syst_key":
69: value = "${azurerm_template_deployment.function_keys.outputs["systemKeys"]}"
|----------------
| azurerm_template_deployment.function_keys.outputs is empty map of string
output "syst_keys" {
value = "${lookup(azurerm_template_deployment.function_keys.outputs, "systemKeys")}"
}
Error: on outputs.tf line 77, in output "syst_key":
77: value = "${lookup(azurerm_template_deployment.function_keys.outputs, "systemKeys")}"
|----------------
| azurerm_template_deployment.function_keys.outputs is empty map of string
Call to function "lookup" failed: lookup failed to find 'systemKeys'.
为了在此功能上触发eventgrid,我必须从我的ARM部署模板中恢复systemKeys的terraform输出中的值.我知道部署工作正常,只是不知道如何使用terraform恢复这些值.
In order to trigger eventgrid on this function I have to recover the values in terraform output of systemKeys from my ARM deployment template. I know that the deployment is working well, I just don't know how to recover theses values with terraform.
推荐答案
对于您的问题,您需要注意只有类型 String , Int 和 Bool .因此,您需要在模板中更改输出类型,然后才能在Terraform中输出它们.有关更多详细信息,请参见输出.在Terraform中正确的输出如下:
For your issue, you need to take care that only the type String, Int and Bool are supported in Terraform. So you need to change the output type in the template, then you can output them in Terraform. For more details, see outputs. And the right output in Terraform is below:
output "syst_key" {
value = "${azurerm_template_deployment.function_keys.outputs["systemKeys"]}"
}
这篇关于使用Terraform输出恢复Azure ARm模板的输出值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!