{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/6359","repository_url":"https://api.github.com/repos/hashicorp/terraform","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/6359/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/6359/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/6359/events","html_url":"https://github.com/hashicorp/terraform/issues/6359","id":151225199,"number":6359,"title":"unable to set consul key with backslash or dollar sign from input variable","user":{"login":"eedwardsdisco","id":12733397,"avatar_url":"https://avatars.githubusercontent.com/u/12733397?v=3","gravatar_id":"","url":"https://api.github.com/users/eedwardsdisco","html_url":"https://github.com/eedwardsdisco","followers_url":"https://api.github.com/users/eedwardsdisco/followers","following_url":"https://api.github.com/users/eedwardsdisco/following{/other_user}","gists_url":"https://api.github.com/users/eedwardsdisco/gists{/gist_id}","starred_url":"https://api.github.com/users/eedwardsdisco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eedwardsdisco/subscriptions","organizations_url":"https://api.github.com/users/eedwardsdisco/orgs","repos_url":"https://api.github.com/users/eedwardsdisco/repos","events_url":"https://api.github.com/users/eedwardsdisco/events{/privacy}","received_events_url":"https://api.github.com/users/eedwardsdisco/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/core","name":"core","color":"cccccc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-04-26T19:58:18Z","updated_at":"2016-04-28T21:39:15Z","closed_at":null,"body":"### Terraform Version\r\n0.6.15\r\n\r\n### Affected Resource(s)\r\n- consul_key_prefix\r\n- core ?\r\n\r\n### Expected Behavior\r\n- Terraform treats default values of variable as 'raw' and does not interpolate or parse them.\r\n- Terraform allows a variable value from a .tfvars file to contain backslashes, or a mechanism to escape them properly\r\n\r\n### Actual Behavior\r\n- Terraform is attempting to parse the 'default' value of a variable containing `${}`, and throwing a \"cannot contain interpolations\" error\r\n- Terraform is attempting to parse the 'default' value of a variable containing `\\:`, and throwing an \"illegal char escape\" error\r\n- Terraform errors if `\\:` is included in a .tfvars file within a value\r\n\r\n### Steps to Reproduce\r\n\r\n#### Unescaped Backslash in Variable (Error)\r\nTF code:\r\n```hcl\r\nvariable \"nlog_console_target_layout\" {\r\n\ttype = \"string\"\r\n\tdefault = \"${date:format=MM/dd HH\\:mm\\:ss} ${logger}|${message}\"\r\n}\r\n```\r\nterraform validate:\r\n```\r\n$ terraform validate\r\nError loading files Error parsing /<snip>/variables.tf: At 65:40: illegal char escape\r\n```\r\n\r\n#### Escaped Backslash in Variable (Escape Character Not Removed)\r\n\r\nTF code:\r\n```hcl\r\nvariable \"nlog_console_target_layout\" {\r\n\ttype = \"string\"\r\n\tdefault = \"${date:format=MM/dd HH\\\\:mm\\\\:ss} ${logger}|${message}\"\r\n}\r\n```\r\n\r\nconsul key value (should not contain extra backslash):\r\n```\r\n${date:format=MM/dd HH\\\\:mm\\\\:ss} ${logger}|${message}\r\n```\r\n\r\n#### Un-Escaped Interpolation Syntax in Variable\r\n\r\nTF code:\r\n```hcl\r\nvariable \"nlog_filelog_target_fileName\" {\r\n\ttype = \"string\"\r\n\tdefault = \"MyApp.${level}.log\"\r\n}\r\n```\r\n\r\nterraform validate:\r\n```\r\n$ terraform validate\r\nError validating: 1 error(s) occurred:\r\n\r\n* Variable 'nlog_filelog_target_fileName': cannot contain interpolations\r\n```\r\n\r\n#### Dollar Escaped Interpolation Syntax in Variable\r\n\r\nTF code:\r\n```hcl\r\nvariable \"nlog_filelog_target_fileName\" {\r\n\ttype = \"string\"\r\n\tdefault = \"MyApp.$${level}.log\"\r\n}\r\n```\r\n\r\nterraform validate:\r\n```\r\n$ terraform validate\r\nError validating: 1 error(s) occurred:\r\n\r\n* Variable 'nlog_filelog_target_fileName': cannot contain interpolations\r\n```\r\n\r\n#### Backslash Escaped Interpolation Syntax in Variable\r\n\r\nTF code:\r\n```hcl\r\nvariable \"nlog_filelog_target_fileName\" {\r\n\ttype = \"string\"\r\n\tdefault = \"MyApp.\\${level}.log\"\r\n}\r\n```\r\n\r\nterraform validate:\r\n```\r\n$ terraform validate\r\nError loading files Error parsing /<snip>/variables.tf: At 89:26: illegal char escape\r\n```\r\n\r\n#### Specifying Value in .tfvars file instead, un-escaped\r\n\r\nvars.tfvars\r\n```\r\nnlog_console_target_layout = \"${date:format=MM/dd HH\\:mm\\:ss} ${logger}|${message}\"\r\n```\r\n\r\nterraform plan\r\n```\r\n$ terraform plan -var-file=vars.tfvars consul_nlog_config-v0.0.7 \r\ninvalid value \"vars.tfvars\" for flag -var-file: Error parsing vars.tfvars: At 14:58: illegal char escape\r\n```\r\n\r\n#### Specifying Value in .tfvars file instead, escaped\r\n\r\nvars.tfvars\r\n```\r\nnlog_console_target_layout = \"${date:format=MM/dd HH\\\\:mm\\\\:ss} ${logger}|${message}\"\r\n```\r\n\r\nconsul key value (should not contain extra backslash):\r\n```\r\n${date:format=MM/dd HH\\\\:mm\\\\:ss} ${logger}|${message}\r\n```\r\n\r\n### Notes\r\nIt appears that the values specified in 'default' aren't always getting ignored for interpolation parsing. I have multiple variables that contain `${}` and they don't always cause the 'cannot contain interpolation syntax' error.\r\n\r\nIt also appears that the backslash is getting treated as an escape character, but if I escape the backslash with another backslash, both backslashes are kept rather than it actually being escaped.\r\n\r\nI suspect this is a problem with validation.\r\n\r\n### References\r\n- https://groups.google.com/forum/#!topic/terraform-tool/Cjq3z3pSCVQ"},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/215571032","html_url":"https://github.com/hashicorp/terraform/issues/6359#issuecomment-215571032","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/6359","id":215571032,"user":{"login":"eedwardsdisco","id":12733397,"avatar_url":"https://avatars.githubusercontent.com/u/12733397?v=3","gravatar_id":"","url":"https://api.github.com/users/eedwardsdisco","html_url":"https://github.com/eedwardsdisco","followers_url":"https://api.github.com/users/eedwardsdisco/followers","following_url":"https://api.github.com/users/eedwardsdisco/following{/other_user}","gists_url":"https://api.github.com/users/eedwardsdisco/gists{/gist_id}","starred_url":"https://api.github.com/users/eedwardsdisco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eedwardsdisco/subscriptions","organizations_url":"https://api.github.com/users/eedwardsdisco/orgs","repos_url":"https://api.github.com/users/eedwardsdisco/repos","events_url":"https://api.github.com/users/eedwardsdisco/events{/privacy}","received_events_url":"https://api.github.com/users/eedwardsdisco/received_events","type":"User","site_admin":false},"created_at":"2016-04-28T21:39:15Z","updated_at":"2016-04-28T21:39:15Z","body":"If this doesn't prove that backslashes are breaking things, I dunno what will...\r\n\r\n**1**\r\n```\r\nvariable \"parse_var\" {\r\n\tdefault = \"this \\\\ string \\\\ contains \\\\ backslashes\"\r\n}\r\n\r\nresource \"template_file\" \"parse_test\" {\r\n\ttemplate = \"${ replace(var.parse_var, \"\\\", \"test\") }\"\r\n}\r\n```\r\n\r\n```\r\no:+ template_file.parse_test\r\n    rendered: \"\" => \"<computed>\"\r\n    template: \"\" => \"testttesthtestiteststest test\\\\test teststestttestrtestitestntestgtest test\\\\test testctestotestntestttestatestitestnteststest test\\\\test testbtestatestctestkteststestltestateststesthtesteteststest\"\r\n```\r\n\r\n**2**\r\n```\r\nvariable \"parse_var\" {\r\n\tdefault = \"this \\\\ string \\\\ contains \\\\ backslashes\"\r\n}\r\n\r\nresource \"template_file\" \"parse_test\" {\r\n\ttemplate = \"${ replace(var.parse_var, \"\\\\\", \"test\") }\"\r\n}\r\n```\r\n```\r\ne:Error loading config: Error loading /Users/ethanedwards/Documents/dev/packages/consul_nlog_config-edwards/parse_test/test.tf: Error reading config for template_file[parse_test]: parse error: syntax error\r\n```"}}