我想构建一个语法如下的模块:
module "order_module" {
service {
name ="some-name"
}
lambda {
name = "some-lambda-name"
}
}
理想情况下,我希望能够以这种方式提供多种服务和功能:
module "order_module" {
service {
name ="some-name"
}
service {
name ="some-name-1"
}
lambda {
name = "some-lambda-name"
}
lambda {
name = "some-lambda-name-2"
}
lambda {
name = "some-lambda-name-3"
}
}
使用变量我可以这样做:
module "order_module" {
service = {
name ="some-name"
}
lambda = {
name = "some-lambda-name"
}
}
但是,当我想提供更多服务时,我需要将它们放在一个列表中:
module "order_module" {
service = [{
name ="some-name"
},
{
name ="some-name-2"
}]
lambda = {
name = "some-lambda-name"
}
}
我没有找到用块构建模块的方法。原生资源有这个:
resource "azurerm_key_vault" "lab" {
name = "${var.app_name}${var.env_name}vault${random_id.lab.dec}"
location = azurerm_resource_group.lab.location
resource_group_name = azurerm_resource_group.lab.name
tenant_id = data.azurerm_client_config.lab.tenant_id
sku_name = "standard"
access_policy {
tenant_id = data.azurerm_client_config.lab.tenant_id
object_id = data.external.lab.result.objectId
key_permissions = []
secret_permissions = [
"list",
"set",
"get",
"delete"
]
}
}
access_policy
以上。这是否可以通过这些块向模块提供参数?