I have a problem trying to rewrite a list to work in Terraform 0.12 that works in Terraform 0.11.
This is my list:
variable "master_authorized_networks_config" {
type = list(string)
description = "The list of CIDR blocks of master authorized networks."
default = [
{
cidr_blocks = [
{
cidr_block = "XXXXXX/32"
display_name = "XXXXX"
},
{
cidr_block = "XXXXXX/32"
display_name = "XXXXX"
},
{
cidr_block = "XXXXXX/32"
display_name = "XXXXX"
},
{
cidr_block = "XXXXXX/32"
display_name = "XXXXX"
},
]
},
]
I added it to module:
master_authorized_networks_config = var.master_authorized_networks_config
After running terraform apply
I get the following error:
Error: Invalid default value for variable
on ../../modules/xxx/xxx/variables.tf line 71, in variable "master_authorized_networks_config":
71: default = [
72: {
73: cidr_blocks = [
74: {
75: cidr_block = "XXXXXX/32"
76: display_name = "XXXXX"
77: },
78: {
79: cidr_block = "XXXXXX/32"
80: display_name = "XXXXX"
81: },
82: {
83: cidr_block = "XXXXXX/32"
84: display_name = "XXXXX"
85: },
86: {
87: cidr_block = "XXXXXX/32"
88: display_name = "XXXXX"
89: },
102: ]
103: },
104: ]
This default value is not compatible with the variable's type constraint:
element 0: string required.
I can't resolve this problem. Can you help me?
list(object)
or remove the type part altogether and allow Terraform to work out the type from the default. The second option is what I'd do. – ydaetskcoRlist(string)
was not an allowed type specification in 0.11. Are you sure you were using this successfully with 0.11? – Matt Schuchard0.12upgrade
when they hadtype = "list"
before and ended up with that. It's been a long time since my 0.12 upgrade but I think that was the default behaviour of the tool. – ydaetskcoR