【发布时间】:2021-11-25 05:30:20
【问题描述】:
我正在尝试将用 HCL 编写的 terraform 变量转换为动态生成的包含该变量的 tf.json 文件,但我遇到了错误。
我正在尝试转换的 HCL 版本:
variable "accounts" {
type = map(any)
default = {
acct1 = ["000000000001"]
acct2 = ["000000000002"]
}
}
我尝试了以下格式:
{
"variable": {
"accounts": {
"type": "map(any)",
"default": [
{ "acct1": "000000000001" },
{ "acct2": "000000000002"}
]
}
}
}
和
{
"variable": {
"accounts": {
"type": "map(any)",
"default": [
{
"acct1": ["000000000001"],
"acct2": ["000000000002"]
}
]
}
}
}
我收到以下错误:
│ Error: Invalid default value for variable
│
│ on accounts.tf.json line 6, in variable.accounts:
│ 6: "default": [
This default value is not compatible with the variable's type constraint: map of any single type required.
是否有工具可以将 HCL 转换为有效的.tf.json 配置?或者我在这里的格式缺少什么?
【问题讨论】: