Terraform - embedded quotation marks

Viewed 2299

In Terraform I can use:

name = "${var.names["apple"])"

which looks up the string "apple" in var.names.

However, this syntax would break in most programming languages as it would try and parse "${var.names[" then apple then "])".

I've looked up documentation on this but failed to find anything. Are there any details?

I've read:

https://www.terraform.io/docs/configuration/syntax.html and https://www.terraform.io/docs/configuration/interpolation.html

The last link briefly gives an example

  template = "${file("templates/web_init.tpl")}"

but doesn't explain.

1 Answers

Upgrade guide to v0.7 explicitly introduces nested quoting context. Apparently this had been allowed since one of the earlier versions, but I could not pinpoint which one exactly.

Related