【发布时间】:2021-06-02 19:42:28
【问题描述】:
Main.tf
locals {
location_mapping = [
{
"url": "L1.tfe.com"
"location": "L1"
"resource_group_name": "R1"
"name_log_workspace_name": "W1"
},
{
"url": "L2.tfe.com"
"location": "L2"
"resource_group_name": "R2"
"name_log_workspace_name": "W2"
},
{
"url": "L3.tfe.com"
"location": "L3"
"resource_group_name": "R3"
"name_log_workspace_name": "W3"
}
]
}
data "azurerm_log_analytics_workspace" "example" {
# Populate name and resource group based on var.location(L2) condition if location matches in locals
name = "W2"
resource_group_name = "R2"
}
我想根据本地数据块中的 location and url 条件动态填充 name 和 resource_group_name。
例子
如果我通过location value L2 和url value L2.tfe.com,那么我将得到name=W2 和resource_group_name=R2
【问题讨论】:
标签: terraform terraform-provider-azure azure-rm terraform-template-file hashicorp