Why do the docs all put single variables values in string templates?

Here is an example from your docs

resource "aws_sns_topic_subscription" "user_updates_sqs_target" {
  topic_arn = "${aws_sns_topic.user_updates.arn}"
  protocol  = "sqs"
  endpoint  = "${aws_sqs_queue.user_updates_queue.arn}"
}

I have tried it out and this works, too:

resource "aws_sns_topic_subscription" "user_updates_sqs_target" {
  topic_arn = aws_sns_topic.user_updates.arn
  protocol  = "sqs"
  endpoint  = aws_sqs_queue.user_updates_queue.arn
}

Why do all the examples use “${var}” instead of just var? Is that to handle spaces or some other character? I find the latter more straightforward to read but want to check before I standardize on it.

THanks

The ${} is the pre 0.12 syntax. It could be a remnant of that. :thinking:

Hi @LGraber,

The provider documentation is currently written for both Terraform 0.11 and 0.12 at once, so many of the examples use this syntax just because it works for both versions and thus avoids showing two examples that would otherwise differ only in the punctuation.

Since you are using Terraform 0.12, you can always “unwrap” expressions of this type where the entire contents of the quotes is a single interpolation sequence, since that is how Terraform 0.12 will always treat expressions like this anyway. It has this automatic unwrapping behavior specifically to allow 0.11-style examples to still work, to give the best chance that existing documentation and articles online (whether in the Terraform provider docs or elsewhere) will still work.

That clears it up. I will use the cleaner, “unwrapped” syntax for my work. Thanks!