【发布时间】:2019-07-09 08:03:21
【问题描述】:
我在 Terraform 中将 Azure Function App 公开为一个模块,我希望该模块允许用户扩展配置参数:
resource "azurerm_function_app" "test" {
name = "${var.prefix}-listener"
resource_group_name = "${var.resource_group_name}"
location = "${var.resource_group_location}"
app_service_plan_id = "${var.app_service_plan_id}"
storage_connection_string = "${var.storage_account_connection_string}"
app_settings = {
HASH = "${data.archive_file.test.output_base64sha256}"
WEBSITE_USE_ZIP = "https://${var.storage_account_name}.blob.core.windows.net/${azurerm_storage_container.test.name}/${azurerm_storage_blob.test.name}${data.azurerm_storage_account_sas.test.sas}"
}
site_config {
always_on = true
}
}
但是,在该示例中,app_settings 是固定的,我希望它可以扩展此地图。比如:
app_settings = ${merge({
HASH = "${data.archive_file.test.output_base64sha256}"
WEBSITE_USE_ZIP = "https://${var.storage_account_name}.blob.core.windows.net/${azurerm_storage_container.test.name}/${azurerm_storage_blob.test.name}${data.azurerm_storage_account_sas.test.sas}"
}, ${var.app_settings})}
我从阅读merge function 中得到了这个想法。但是我收到 Invalid expression 错误。
这里的正确语法是什么?
【问题讨论】:
-
您的
${var.app_settings}定义是什么?是地图吗? -
@NancyXiong 是的
-
试试这个:
app_settings = "${merge({ "HASH" = "${data.archive_file.test.output_base64sha256}", "WEBSITE_USE_ZIP" = "https://${var.storage_account_name}.blob.core.windows.net/${azurerm_storage_container.test.name}/${azurerm_storage_blob.test.name}${data.azurerm_storage_account_sas.test.sas}" }, "${var.app_settings}")}"
标签: terraform terraform-provider-azure