I've been working on some terraform code in a single file (main.tf). Now that it is working as expected I want build out a module for it.
I want to make this hard-coded variable an input variable. So I copy/pasted into modules variables.tf file.
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" },
}
To confirm, yes it works with no problems in a single 'main.tf' file. When I try it as an input variable I get the following error.
$ 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.
I'm not sure why this is treated differently when defined in variables.tf. Any thoughts?