【发布时间】:2021-06-11 00:09:45
【问题描述】:
我一直在处理单个文件 (main.tf) 中的一些 terraform 代码。现在它按预期工作了,我想为它构建一个模块。
我想让这个硬编码变量成为输入变量。所以我复制/粘贴到模块 variables.tf 文件中。
variable "subnet-map" {
type = map
default = {
aznum = 0, bits = 8, netnum = 0, desc = "some description" },
{ aznum = 1, bits = 8, netnum = 1, desc = "some description" },
{ aznum = 2, bits = 8, netnum = 2, desc = "some description" },
{ aznum = 0, bits = 8, netnum = 3, desc = "some description" },
{ aznum = 1, bits = 8, netnum = 4, desc = "some description" },
{ aznum = 2, bits = 8, netnum = 5, desc = "some description" },
{ aznum = 0, bits = 8, netnum = 6, desc = "some description" },
{ aznum = 1, bits = 8, netnum = 7, desc = "some description" },
{ aznum = 2, bits = 8, netnum = 8, desc = "some description" },
{ aznum = 0, bits = 8, netnum = 9, desc = "some description" },
{ aznum = 1, bits = 8, netnum = 10, desc = "some description" },
{ aznum = 2, bits = 8, netnum = 11, desc = "some description" },
}
确认一下,是的,它在单个“main.tf”文件中没有问题。 当我尝试将其作为输入变量时,出现以下错误。
$ terraform apply
Error: Unexpected comma after argument
on modules/my-aws-subnet/variables.tf line 17, in variable "subnet-map":
16: default = {
17: aznum = 0, bits = 8, netnum = 0, desc = "some description" },
Argument definitions must be separated by newlines, not commas. An argument
definition must end with a newline.
我不确定为什么在 variables.tf 中定义时会以不同方式对待它。有什么想法吗?
【问题讨论】:
-
在我所有的迭代中,似乎我在这里复制粘贴错误,抱歉。最后我让它像这样工作:
标签: terraform