【发布时间】:2020-02-05 02:01:36
【问题描述】:
我是 terraform 的新手,我创建了一个关于模块结构的自定义 azure 策略。
每个策略代表一个自定义模块。
我创建的模块之一是为创建的任何新 Azure 资源启用诊断日志。
但是,我需要一个存储帐户。 (在启用诊断设置之前,我如何实施 "depends_on"?或任何其他方法?
我想先创建存储帐户,然后再创建诊断设置模块。
在main.tf(调用所有其他模块的地方)还是在资源(模块)内部?
感谢您的帮助! :)
以下代码代表 main.tf 文件:
//calling the create storage account name
module "createstorageaccount" {
source = "./modules/module_create_storage_account"
depends_on = [
"module_enable_diagnostics_logs"
]
}
这个代表创建存储账户模块
resource "azurerm_resource_group" "management" {
name = "management-rg"
location = "West Europe"
}
resource "azurerm_storage_account" "test" {
name = "diagnostics${azurerm_resource_group.management.name}"
resource_group_name = "${azurerm_resource_group.management.name}"
location = "${azurerm_resource_group.management.location}"
account_tier = "Standard"
account_replication_type = "LRS"
tags = {
environment = "diagnostics"
}
}
depends_on = [
"module_enable_diagnostics_logs"
]
【问题讨论】:
-
据我所知,depends_on 适用于资源,而不是模块
-
请参阅medium.com/mineiros/…,了解如何实现更通用的 module_depends_on ..
-
由于0.13 现在可以拥有
depend_onon modules
标签: azure terraform terraform-provider-azure