{"action":"opened","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/18322","repository_url":"https://api.github.com/repos/hashicorp/terraform","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/18322/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/18322/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/18322/events","html_url":"https://github.com/hashicorp/terraform/issues/18322","id":335267711,"node_id":"MDU6SXNzdWUzMzUyNjc3MTE=","number":18322,"title":"Cannot access values in a list of maps","user":{"login":"megakoresh","id":5512531,"node_id":"MDQ6VXNlcjU1MTI1MzE=","avatar_url":"https://avatars2.githubusercontent.com/u/5512531?v=4","gravatar_id":"","url":"https://api.github.com/users/megakoresh","html_url":"https://github.com/megakoresh","followers_url":"https://api.github.com/users/megakoresh/followers","following_url":"https://api.github.com/users/megakoresh/following{/other_user}","gists_url":"https://api.github.com/users/megakoresh/gists{/gist_id}","starred_url":"https://api.github.com/users/megakoresh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/megakoresh/subscriptions","organizations_url":"https://api.github.com/users/megakoresh/orgs","repos_url":"https://api.github.com/users/megakoresh/repos","events_url":"https://api.github.com/users/megakoresh/events{/privacy}","received_events_url":"https://api.github.com/users/megakoresh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-25T05:50:05Z","updated_at":"2018-06-25T05:50:05Z","closed_at":null,"author_association":"NONE","body":"There is no way to access map values inside a list of maps when it is passed to a module as a variable. I have tried the following to no avail:\r\n\r\n```\r\n${lookup(element(var.list_of_maps, count.index), \"key_name\")}\r\n${element(var.list_of_maps.*.key_name, count.index)}\r\n${lookup(var.list_of_maps[count.index], \"key_name\")}\r\n```\r\n\r\nLookups and element functions don't work because for whatever reason they don't support any value complexity (that is if nested values are anything but strings, they will crash). \r\n\r\nSeemed like the splat operator might do the trick but apparently it can't be used on variables. This is critical functionality for making reusable modules, and it is quite a basic one, so I suspect this is either a bug or an oversight - at any rate there is nothing in the documentation that says splat operators can't be used on variables.\r\n\r\n### Terraform Version\r\n```\r\nTerraform v0.11.7\r\n+ provider.openstack v1.6.0\r\n```\r\n\r\n### Terraform Configuration Files\r\n\r\nCode in module:\r\n\r\n```hcl\r\nresource \"openstack_networking_subnetpool_v2\" \"subnetpool_ipv6\" {\r\n  count      = \"${length(var.subnets)}\"\r\n  name       = \"${element(var.subnets.*.name, count.index)}_ipv6\"\r\n  ip_version = 6\r\n  prefixes   = \"${element(var.subnets.*.pool_ipv6_prefixes, count.index)}\"\r\n}\r\n```\r\n\r\nCalling module:\r\n\r\n```hcl\r\nmodule \"customized_network\" {\r\n  source = \"../../network/flat\"\r\n  router_name           = \"custom-router\"\r\n  network_name          = \"custom-net\"\r\n  external_network_name = \"ext-net\"\r\n\r\n  subnets = [\r\n    {\r\n      name               = \"subnet1\"\r\n      pool_ipv6_prefixes = [\"2001:998:33:16ff::/120\"]\r\n      pool_ipv4_prefixes = [\"192.170.0.0/24\"]\r\n      cidr_ipv6          = \"2001:998:33:16ff::/116\"\r\n      cidr_ipv4          = \"193.170.0.0/24\"\r\n      enable_dhcp        = true\r\n    },\r\n    {\r\n      name               = \"subnet2\"\r\n      pool_ipv6_prefixes = [\"2001:998:33:16ff::/96\"]\r\n      pool_ipv4_prefixes = [\"192.170.1.0/24\"]\r\n      cidr_ipv6          = \"2001:998:33:16ff::fff/96\"\r\n      cidr_ipv4          = \"192.170.1.0/24\"\r\n      enable_dhcp        = true\r\n    },\r\n  ]\r\n}\r\n```\r\n\r\n### Debug Output\r\n<!--\r\nFull debug output can be obtained by running Terraform with the environment variable `TF_LOG=trace`. Please create a GitHub Gist containing the debug output. Please do _not_ paste the debug output in the issue, since debug output is long.\r\n\r\nDebug output may contain sensitive information. Please review it before posting publicly, and if you are concerned feel free to encrypt the files using the HashiCorp security public key.\r\n-->\r\n\r\n### Crash Output\r\n```\r\nError downloading modules: Error loading modules: module customized_network: Error loading .terraform/modules/4ae54b31c728d74827e62ddca10b3686/main.tf: Error reading config for openstack_networking_subnetpool_v2[subnetpool_ipv6]: Invalid dot index found: 'var.subnets.*.name'. Values in maps and lists can be referenced using square bracket indexing, like: 'var.mymap[\"key\"]' or 'var.mylist[1]'. in:\r\n\r\n${element(var.subnets.*.name, count.index)}_ipv6\r\n```\r\n\r\n### Expected Behavior\r\nThe value in list of maps should have been used.\r\n\r\n### Actual Behavior\r\nNo attempted methods have been found to utilize values in a statically defined list of maps in any way.\r\n\r\n### Steps to Reproduce\r\n1. Create a module that uses a list of maps variable, which extracts values from the map\r\n2. Use the module\r\n\r\n### Additional Context\r\nN/A\r\n\r\n### References\r\nN/A\r\n"}}
{"actor":{"display_login":"megakoresh"}}