{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/2306","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/2306/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/2306/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/2306/events","html_url":"https://github.com/hashicorp/terraform/issues/2306","id":87033937,"number":2306,"title":"template_file unexpectedly reports unknown variable","user":{"login":"gamepoet","id":969326,"avatar_url":"https://avatars.githubusercontent.com/u/969326?v=3","gravatar_id":"","url":"https://api.github.com/users/gamepoet","html_url":"https://github.com/gamepoet","followers_url":"https://api.github.com/users/gamepoet/followers","following_url":"https://api.github.com/users/gamepoet/following{/other_user}","gists_url":"https://api.github.com/users/gamepoet/gists{/gist_id}","starred_url":"https://api.github.com/users/gamepoet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gamepoet/subscriptions","organizations_url":"https://api.github.com/users/gamepoet/orgs","repos_url":"https://api.github.com/users/gamepoet/repos","events_url":"https://api.github.com/users/gamepoet/events{/privacy}","received_events_url":"https://api.github.com/users/gamepoet/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hashicorp/terraform/labels/bug","name":"bug","color":"f7c6c7"},{"url":"https://api.github.com/repos/hashicorp/terraform/labels/provider/template","name":"provider/template","color":"bfdadc"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-06-10T16:48:38Z","updated_at":"2015-06-29T06:42:33Z","closed_at":"2015-06-29T06:42:33Z","body":"I accidentally made a typo with an output variable from a count-based resource in that I didn't use a splat or an index in the interpolation. When I tried to use that output as a variable for a template_file, terraform complained that the template variable was unknown. This was quite confusing for me since it seemed to suggest that the template definition was incorrect. A simple repro is below. Tested with 0.5.3 and aed44622b121cb7f4f7633b59de852bf39e48843.\r\n\r\n```\r\n$ mkdir a\r\n$ cat > a/a.tf\r\nprovider \"aws\" {\r\n    region = \"us-west-2\"\r\n}\r\nresource \"aws_instance\" \"server\" {\r\n    ami           = \"ami-6989a659\"\r\n    instance_type = \"t1.micro\"\r\n    count         = 2\r\n}\r\noutput \"private_ip\" {\r\n    value = \"${aws_instance.server.private_ip}\" # note this is not aws_instance.server.0.private_ip\r\n}\r\n$ cat > main.tf\r\nmodule \"a\" {\r\n    source = \"./a\"\r\n}\r\nresource \"template_file\" \"ips\" {\r\n    filename = \"template.txt\"\r\n    vars {\r\n        private_ip = \"${module.a.private_ip}\"\r\n    }\r\n}\r\n$ cat > template.txt\r\nuri: http://${private_ip}\r\n$ terraform get\r\nGet: file:///Users/ben/dev/work/tf-template-bug/a\r\n$ terraform apply\r\nmodule.a.aws_instance.server.0: Creating...\r\n  ami:                      \"\" => \"ami-6989a659\"\r\n  availability_zone:        \"\" => \"<computed>\"\r\n  ebs_block_device.#:       \"\" => \"<computed>\"\r\n  ephemeral_block_device.#: \"\" => \"<computed>\"\r\n  instance_type:            \"\" => \"t1.micro\"\r\n  key_name:                 \"\" => \"<computed>\"\r\n  placement_group:          \"\" => \"<computed>\"\r\n  private_dns:              \"\" => \"<computed>\"\r\n  private_ip:               \"\" => \"<computed>\"\r\n  public_dns:               \"\" => \"<computed>\"\r\n  public_ip:                \"\" => \"<computed>\"\r\n  root_block_device.#:      \"\" => \"<computed>\"\r\n  security_groups.#:        \"\" => \"<computed>\"\r\n  subnet_id:                \"\" => \"<computed>\"\r\n  tenancy:                  \"\" => \"<computed>\"\r\n  vpc_security_group_ids.#: \"\" => \"<computed>\"\r\nmodule.a.aws_instance.server.1: Creating...\r\n  ami:                      \"\" => \"ami-6989a659\"\r\n  availability_zone:        \"\" => \"<computed>\"\r\n  ebs_block_device.#:       \"\" => \"<computed>\"\r\n  ephemeral_block_device.#: \"\" => \"<computed>\"\r\n  instance_type:            \"\" => \"t1.micro\"\r\n  key_name:                 \"\" => \"<computed>\"\r\n  placement_group:          \"\" => \"<computed>\"\r\n  private_dns:              \"\" => \"<computed>\"\r\n  private_ip:               \"\" => \"<computed>\"\r\n  public_dns:               \"\" => \"<computed>\"\r\n  public_ip:                \"\" => \"<computed>\"\r\n  root_block_device.#:      \"\" => \"<computed>\"\r\n  security_groups.#:        \"\" => \"<computed>\"\r\n  subnet_id:                \"\" => \"<computed>\"\r\n  tenancy:                  \"\" => \"<computed>\"\r\n  vpc_security_group_ids.#: \"\" => \"<computed>\"\r\nmodule.a.aws_instance.server.0: Creation complete\r\nmodule.a.aws_instance.server.1: Creation complete\r\ntemplate_file.ips: Creating...\r\n  filename: \"\" => \"template.txt\"\r\n  rendered: \"\" => \"<computed>\"\r\n  vars.#:   \"\" => \"<computed>\"\r\ntemplate_file.ips: Error: 1 error(s) occurred:\r\n\r\n* failed to render template.txt: 1:15: unknown variable accessed: private_ip\r\nError applying plan:\r\n\r\n1 error(s) occurred:\r\n\r\n* 1 error(s) occurred:\r\n\r\n* 1 error(s) occurred:\r\n\r\n* failed to render template.txt: 1:15: unknown variable accessed: private_ip\r\n\r\nTerraform does not automatically rollback in the face of errors.\r\nInstead, your Terraform state file has been partially updated with\r\nany resources that successfully completed. Please address the error\r\nabove and apply again to incrementally change your infrastructure.\r\n```"},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/116480429","html_url":"https://github.com/hashicorp/terraform/issues/2306#issuecomment-116480429","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/2306","id":116480429,"user":{"login":"mitchellh","id":1299,"avatar_url":"https://avatars.githubusercontent.com/u/1299?v=3","gravatar_id":"","url":"https://api.github.com/users/mitchellh","html_url":"https://github.com/mitchellh","followers_url":"https://api.github.com/users/mitchellh/followers","following_url":"https://api.github.com/users/mitchellh/following{/other_user}","gists_url":"https://api.github.com/users/mitchellh/gists{/gist_id}","starred_url":"https://api.github.com/users/mitchellh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitchellh/subscriptions","organizations_url":"https://api.github.com/users/mitchellh/orgs","repos_url":"https://api.github.com/users/mitchellh/repos","events_url":"https://api.github.com/users/mitchellh/events{/privacy}","received_events_url":"https://api.github.com/users/mitchellh/received_events","type":"User","site_admin":false},"created_at":"2015-06-29T06:42:33Z","updated_at":"2015-06-29T06:42:33Z","body":"This should be fixed"}}