【发布时间】:2021-12-28 22:37:04
【问题描述】:
我有一个自定义 terraform 提供程序,其资源将列表作为其输入之一。
当我声明列表时,它需要设置为多个块,如下所示:
active_service_policies {
policies {
name = "foobar"
namespace = "shared"
}
policies {
name = "batz"
namespace = "shared"
}
}
相反,我希望能够像下面这样声明它:
active_service_policies {
policies = [
{
name = "foobar"
namespace = "shared"
},
{
name = "batz"
namespace = "shared"
}
]
}
这会导致以下错误:
Error: Unsupported argument
on main.tf line 79, in resource "volterra_http_loadbalancer" "sp":
79: policies = [
An argument named "policies" is not expected here. Did you mean to define a block
of type "policies"?
为什么我不能使用有序列表,如何允许使用它?
这个问题是因为policies 是Type: schema.TypeList, 应该是TypeSet 还是其他一些对象?
【问题讨论】:
-
我们需要在您的提供程序代码中查看资源架构。
-
我不相信 SDK 支持其架构中资源参数中的嵌套映射,因此您最接近的应该是
list和elem或map和string。但是,这需要是“顶级的”。
标签: terraform hcl terraform-provider