{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/15605","repository_url":"https://api.github.com/repos/hashicorp/terraform","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/15605/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/15605/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/15605/events","html_url":"https://github.com/hashicorp/terraform/issues/15605","id":244538929,"number":15605,"title":"Interpolation should only evaluate one branch of a condition","user":{"login":"Kentzo","id":88809,"avatar_url":"https://avatars1.githubusercontent.com/u/88809?v=4","gravatar_id":"","url":"https://api.github.com/users/Kentzo","html_url":"https://github.com/Kentzo","followers_url":"https://api.github.com/users/Kentzo/followers","following_url":"https://api.github.com/users/Kentzo/following{/other_user}","gists_url":"https://api.github.com/users/Kentzo/gists{/gist_id}","starred_url":"https://api.github.com/users/Kentzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kentzo/subscriptions","organizations_url":"https://api.github.com/users/Kentzo/orgs","repos_url":"https://api.github.com/users/Kentzo/repos","events_url":"https://api.github.com/users/Kentzo/events{/privacy}","received_events_url":"https://api.github.com/users/Kentzo/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":608979767,"url":"https://api.github.com/repos/hashicorp/terraform/labels/config","name":"config","color":"0e8a16","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-07-21T01:19:55Z","updated_at":"2018-03-22T16:35:19Z","closed_at":null,"author_association":"NONE","body":"Conditionals are handy, but it looks like both branches are always evaluated.\r\n\r\nMy specific use case is that I want to have a variable that may or may not point to a file:\r\n\r\n```hcl\r\n# variables.tf\r\n\r\nvariable \"file_path\" {\r\n  default = \"\"\r\n}\r\n\r\n# main.tf\r\n\r\ndata \"template_file\" \"template\" {\r\n  vars {\r\n    file_contents = \"${length(var.file_path) > 0 ? file(\"${var.file_path}\") : \"\"}\"\r\n  }\r\n}\r\n```\r\n\r\nHowever I always get the \"file: open : no such file or directory in:\" error, even if I change conditional to:\r\n\r\n```hcl\r\n\"${false ? file(\"${var.file_path}\") : \"\"}\"\r\n```"},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/375372141","html_url":"https://github.com/hashicorp/terraform/issues/15605#issuecomment-375372141","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/15605","id":375372141,"user":{"login":"dan-rose","id":22326621,"avatar_url":"https://avatars1.githubusercontent.com/u/22326621?v=4","gravatar_id":"","url":"https://api.github.com/users/dan-rose","html_url":"https://github.com/dan-rose","followers_url":"https://api.github.com/users/dan-rose/followers","following_url":"https://api.github.com/users/dan-rose/following{/other_user}","gists_url":"https://api.github.com/users/dan-rose/gists{/gist_id}","starred_url":"https://api.github.com/users/dan-rose/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dan-rose/subscriptions","organizations_url":"https://api.github.com/users/dan-rose/orgs","repos_url":"https://api.github.com/users/dan-rose/repos","events_url":"https://api.github.com/users/dan-rose/events{/privacy}","received_events_url":"https://api.github.com/users/dan-rose/received_events","type":"User","site_admin":false},"created_at":"2018-03-22T16:35:19Z","updated_at":"2018-03-22T16:35:19Z","author_association":"NONE","body":"If any one can help then we hit this error too - \r\n\r\nname_prefix = \"${length(var.customer_name) < 5 ? \"${var.customer_name}-\" : \"${substr(var.customer_name, 0, 5)}-\"}\"\r\n\r\nsubstr: 'offset + length' cannot be larger than the length of the string"}}
{"actor":{"display_login":"dan-rose"}}