{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/13828","repository_url":"https://api.github.com/repos/hashicorp/terraform","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/13828/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/13828/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/13828/events","html_url":"https://github.com/hashicorp/terraform/issues/13828","id":223213760,"number":13828,"title":"index out of range when using splat square bracket indexing in template_file input","user":{"login":"sjwl","id":15661752,"avatar_url":"https://avatars0.githubusercontent.com/u/15661752?v=3","gravatar_id":"","url":"https://api.github.com/users/sjwl","html_url":"https://github.com/sjwl","followers_url":"https://api.github.com/users/sjwl/followers","following_url":"https://api.github.com/users/sjwl/following{/other_user}","gists_url":"https://api.github.com/users/sjwl/gists{/gist_id}","starred_url":"https://api.github.com/users/sjwl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjwl/subscriptions","organizations_url":"https://api.github.com/users/sjwl/orgs","repos_url":"https://api.github.com/users/sjwl/repos","events_url":"https://api.github.com/users/sjwl/events{/privacy}","received_events_url":"https://api.github.com/users/sjwl/received_events","type":"User","site_admin":false},"labels":[{"id":85946957,"url":"https://api.github.com/repos/hashicorp/terraform/labels/bug","name":"bug","color":"f7c6c7","default":true},{"id":127939292,"url":"https://api.github.com/repos/hashicorp/terraform/labels/core","name":"core","color":"cccccc","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-04-20T22:01:10Z","updated_at":"2017-04-24T14:35:44Z","closed_at":null,"body":"### Terraform Version\r\n0.9.3\r\n\r\n### Affected Resource(s)\r\nAll\r\n\r\n### Terraform Configuration Files\r\n```hcl\r\nvariable count { default = 1 }\r\n\r\nresource \"test_resource\" \"foo\" {\r\n  count = \"${var.count}\"\r\n  required = \"foo\"\r\n\r\n  required_map {\r\n    bar = \"bar\"\r\n  }\r\n\r\n}\r\n\r\ndata \"template_file\" \"my_script\" {\r\n  template = \"$${x}:1234\"\r\n  count    = \"${var.count}\"\r\n\r\n  vars {\r\n  x = \"${test_resource.foo.*.required[count.index]}\"\r\n  }\r\n}\r\n```\r\n\r\n### Expected Behavior\r\nChanging count up or down should add or remove resources accordingly.\r\n\r\n### Actual Behavior\r\n```\r\nError refreshing state: 1 error(s) occurred:\r\n\r\n* data.template_file.my_script: 1 error(s) occurred:\r\n\r\n* data.template_file.my_script[1]: index 1 out of range for list test_resource.foo.*.required (max 1) in:\r\n\r\n${test_resource.foo.*.required[count.index]}\r\n```\r\n### Steps to Reproduce\r\n\r\n1. `TF_VAR_count=1 terraform apply`\r\n2. `TF_VAR_count=2 terraform plan`\r\n\r\nThe first step works, but the error happens on the second step.  Same error if the count is increasing or decreasing.\r\n\r\n### Important Factoids\r\n~~The workaround is to use `element()` instead of square bracket notation~~\r\n"},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/296688158","html_url":"https://github.com/hashicorp/terraform/issues/13828#issuecomment-296688158","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/13828","id":296688158,"user":{"login":"sjwl","id":15661752,"avatar_url":"https://avatars0.githubusercontent.com/u/15661752?v=3","gravatar_id":"","url":"https://api.github.com/users/sjwl","html_url":"https://github.com/sjwl","followers_url":"https://api.github.com/users/sjwl/followers","following_url":"https://api.github.com/users/sjwl/following{/other_user}","gists_url":"https://api.github.com/users/sjwl/gists{/gist_id}","starred_url":"https://api.github.com/users/sjwl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjwl/subscriptions","organizations_url":"https://api.github.com/users/sjwl/orgs","repos_url":"https://api.github.com/users/sjwl/repos","events_url":"https://api.github.com/users/sjwl/events{/privacy}","received_events_url":"https://api.github.com/users/sjwl/received_events","type":"User","site_admin":false},"created_at":"2017-04-24T14:35:44Z","updated_at":"2017-04-24T14:35:44Z","body":"@vancluever I tried it, and looked promising at first.  \r\n\r\n1. `TF_VAR_count=1 terraform apply`  (WORKED, as expected)\r\n2. `TF_VAR_count=2 terraform apply` (WORKED, yah)\r\n3. `TF_VAR_count=3 terraform apply` (ERROR)\r\n```\r\nError refreshing state: 1 error(s) occurred:\r\n\r\n* data.template_file.my_script: 1 error(s) occurred:\r\n\r\n* data.template_file.my_script[2]: index 2 out of range for list test_resource.foo.*.required (max 2) in:\r\n\r\n${test_resource.foo.*.required[count.index]}\r\n```\r\n"}}
{"actor":{"display_login":"sjwl"}}