-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Unable to express list of maps as a literal in variables #7142
Comments
Worth noting that a list of maps can be expressed in both Examples: module "foo" {
source = "./foo"
listofmaps {
foo = 1
}
listofmaps {
bar = 2
}
} resource "aws_instance" "foo" {
ebs_block_device {
device = "/dev/xvda"
# ...
}
ebs_block_device {
# ...
device = "/dev/xvdb"
}
} |
Related a bit to #7030 |
Also duplicate of #7032? Have you verified that setting tags from a list of maps variable like this works? I got an error when I tried: aws_elastic_beanstalk_environment.myEnv: gob: type not registered for interface: map[string]ast.Variable |
a.k.a lists of maps Implementation was pretty straightforward - I had to tweak the `needsComma` handling since it was stuck inside literal parsing. It happens out front now. I also promoted the `assign_deep.hcl` parser test to a decoder test that passes, since it was testing for an error to occur but now it works! :) Refs hashicorp/terraform#7142
a.k.a lists of maps Implementation was pretty straightforward - I had to tweak the `needsComma` handling since it was stuck inside literal parsing. It happens out front now. I also promoted the `assign_deep.hcl` parser test to a decoder test that passes, since it was testing for an error to occur but now it works! :) Additionally we make ObjectLists support being comma-delimited, which enables maps to defined inline like `{one = 1, two = 2}`. Refs hashicorp/terraform#7142
a.k.a lists of maps Implementation was pretty straightforward - I had to tweak the `needsComma` handling since it was stuck inside literal parsing. It happens out front now. I also promoted the `assign_deep.hcl` parser test to a decoder test that passes, since it was testing for an error to occur but now it works! :) Additionally we make ObjectLists support being comma-delimited, which enables maps to defined inline like `{one = 1, two = 2}`. Refs hashicorp/terraform#7142
@phinze Would it be beneficial to mention this in https://www.terraform.io/docs/configuration/interpolation.html or https://www.terraform.io/docs/configuration/variables.html? |
This is marked as closed, but I can't seem to figure out what the actual syntax is. This seems to produce only a single map: variable "list_of_maps" {
default {
id = "747381f4"
key_permissions = ["get"]
secret_permissions = ["get"]
}
default {
id = "c411a1534b6e"
key_permissions = ["get"]
secret_permissions = ["get"]
}
} |
Syntax is:
|
@phinze in your example, how would you declare My hope is I can do this: variable "listofmaps" { type = "list" }
module "foo" {
# This would end up as ${var.listofmaps.0}
listofmaps {
bar = "baz"
}
} |
@joestump yep! the variable inside the module will just be "list" as that's the top-level type |
For anyone else trying to figure out how to access an attribute of a specific map, try:
Replacing |
@phinze I'm unable to get your example working. Using Terraform 0.10.2:
Yet if I change
|
Hi @ericlagergren - that looks correct from here! I'd recommend posting your repro as a fresh issue and referencing back to this one. |
the above is not a solution when you want to concatenate a list of maps to another (the one is declared inline and the other from a variable) maybe iterating though the provided would... |
I think this is still an issue. I really don't see a way of generating a list of maps from a list. locals {
ports = [22, 80, 443]
}
resource "digitalocean_firewall" "host" {
name = "some_name"
droplet_ids = ["${digitalocean_droplet.host.*.id}"]
inbound_rule = [
{
protocol = "tcp"
port_range = "${local.open_ports.*}"
}
]
} I don't see how currently this is possible. |
Could it work if instead of llimited HCL templates we would use a json template? |
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. |
Perhaps this one will be a
wontfix
for 0.7.0, but I wanted to get it recorded.Terraform Version
master / 2127466
Affected Resource(s)
core
Terraform Configuration Files
Steps to Reproduce
terraform apply
Expected Behavior
3 SGs each with a zone tag.
Actual Behavior
The text was updated successfully, but these errors were encountered: