Reputation: 53
I am using terraform 0.11 for a custom module implementation of terraform-aws-provider. Inside the module there are a lot of unquoted resource value assignments that make me confused since they are not working.
This is the sample module code that I am using
resource "aws_iam_policy" "example" {
name = example_policy
policy = data.aws_iam_policy_document.example.json
}
In the official terraform documentation, it was given with interpolation around the value to become
resource "aws_iam_policy" "example" {
name = "example_policy"
policy = "${data.aws_iam_policy_document.example.json}"
}
from: https://www.terraform.io/docs/providers/aws/d/iam_policy_document.html
When I tried to do terraform get
the following error message came up:
Unknown token: 39:24 IDENT data.aws_iam_policy_document.example.json
and when I tried to use terraform 0.12, it managed to fetch it correctly.
Is this unquoted resource value exclusive to terraform > v0.12?
Upvotes: 1
Views: 588
Reputation: 3244
Yes. Terraform 0.11 requires that all references look like string interpolations (like your second example). Terraform 0.12 added support for first-class expressions which let you reference variables outside of strings (like your first example).
The docs also include an example of the newer, cleaner syntax:
# Old 0.11 example
tags = "${merge(map("Name", "example"), var.common_tags)}"
# Updated 0.12 example
tags = merge({ Name = "example" }, var.common_tags)
Upvotes: 4