Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not accepting maps from a var file! #8057

Closed
jsonmaur opened this issue Aug 8, 2016 · 4 comments · Fixed by #9268
Closed

Not accepting maps from a var file! #8057

jsonmaur opened this issue Aug 8, 2016 · 4 comments · Fixed by #9268

Comments

@jsonmaur
Copy link

jsonmaur commented Aug 8, 2016

Terraform Version: v0.7.0
Affected Resource: Terraform Core

terraform.tvfars
somemap = {
  foo = "bar"
  baz = "qux"
}
main.tf
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.

@lamanotrama
Copy link

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

@brikis98
Copy link
Contributor

brikis98 commented Aug 30, 2016

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 = {}
}

@jamtur01
Copy link
Contributor

jamtur01 commented Oct 3, 2016

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. :)

@ghost
Copy link

ghost commented Apr 21, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants