Escaping quotes in strings

1,883 views
Skip to first unread message

Ron Pantofaro

unread,
Oct 10, 2014, 11:57:41 AM10/10/14
to terrafo...@googlegroups.com
I saw in the HCL code that it should support escaping quotes if i use \" , but when i tried it in terraform I got errors for that.
Am I using it wrong?

Ryan B

unread,
Oct 10, 2014, 2:07:33 PM10/10/14
to terrafo...@googlegroups.com
I ran in to the same thing.  If you can use single quoutes it works fine.

-r

Ron Pantofaro

unread,
Oct 10, 2014, 2:09:59 PM10/10/14
to terrafo...@googlegroups.com
I had a very complex command line, that bash escaping it with single quotes turned out to be pretty ugly. The other alternative was to prepare a bash script, but that was an overkill. Both weren't my number one choices, but i went with the first.
It would be great to have the escaping in terraform as well.

Ryan B

unread,
Oct 10, 2014, 2:46:15 PM10/10/14
to terrafo...@googlegroups.com
Actually I prefer the script method over a long complex command.  The only drawbacks are you can't use built in terraform variables in your script.  Also i seem to remember from my testing that you can't use parameters/switches in the script line.  You can only provide the scriptfile to be copied and executed remotely.  Which means if you wanted to run a script you wrote that takes parameters you'll have to do it in 2 steps:   you'll need to first upload it with the file provisioner then use the remote-exec inline provisioner to execute it with parameters/switches.

-r

Ron Pantofaro

unread,
Oct 10, 2014, 2:55:06 PM10/10/14
to terrafo...@googlegroups.com
Oh I just copy my scripts and then run them with remote-exec.

Mitchell Hashimoto

unread,
Oct 10, 2014, 7:10:28 PM10/10/14
to Ron Pantofaro, <terraform-tool@googlegroups.com>
Ron,

We just pushed a fix to hashicorp/hcl to fix this. The next version of
Terraform will include this fix.

Best,
Mitchell
> --
> You received this message because you are subscribed to the Google Groups
> "Terraform" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to terraform-too...@googlegroups.com.
> To post to this group, send email to terrafo...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/terraform-tool/c2d6a212-82fb-4f25-98b4-3423fdf0006a%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Ron Pantofaro

unread,
Oct 11, 2014, 12:37:29 PM10/11/14
to Mitchell Hashimoto, <terraform-tool@googlegroups.com>
How do I get this fix now? Do i just build terraform's master branch?

Mitchell Hashimoto

unread,
Oct 11, 2014, 12:51:13 PM10/11/14
to Ron Pantofaro, <terraform-tool@googlegroups.com>
Ron,

You could, but warning that master is well... unreleased by nature.

Make sure you run a `make updatedeps` as well since the fix was
actually in an upstream dependency.

Best,
Mitchell

David Cunningham

unread,
Oct 11, 2014, 5:42:16 PM10/11/14
to Mitchell Hashimoto, Ron Pantofaro, <terraform-tool@googlegroups.com>
Does this bug affect JSON input too?

Mitchell Hashimoto

unread,
Oct 11, 2014, 6:31:11 PM10/11/14
to David Cunningham, Ron Pantofaro, <terraform-tool@googlegroups.com>
David,

JSON already was able to escape, I checked!

Best,
Mitchell
Reply all
Reply to author
Forward
0 new messages