Terraform Version: v0.7.0
Affected Resource: Terraform Core
somemap = {
foo = "bar"
baz = "qux"
}
variable "somemap" {
type = "map"
}
output "somemap" {
value = "${var.somemap}"
}
This should simply output the map. But instead, I get this error:
variable somemap should be type map, got list
It works as expected if I run TF_VAR_somemap='{foo = "bar", baz = "qux"}' terraform apply. Another interesting tidbit--if I change the var type to variable "somemap" { type = "list" }, I get the error: variable somemap should be type list, got list.
According to the docs here, this should work.
Though this is just a workaround, I was able to avoid this kind of error when set default = {}.
e.g.
variable "somemap" {
type = "map"
default = {}
}
I comfirmed it in ver 0.7.0 and 0.7.1
Just hit the same issue with Terraform 0.7.2 trying to pass an empty map from the command-line. The Terraform template:
variable "foo" {
type = "map"
}
Trying to set the variable from the command-line:
terraform apply -var 'foo = {}'
This caused the error:
* variable foo should be type map, got list
@lamanotrama's workaround helped:
variable "foo" {
type = "map"
default = {}
}
Hi - just wondering if there's plans to work on this - if not - I'd be happy (and would suggest) a docs update - because this is very counter-intuitive. :)
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
Though this is just a workaround, I was able to avoid this kind of error when set
default = {}.e.g.
I comfirmed it in ver 0.7.0 and 0.7.1