I am new to terraform using vs code and the "Terraform" extension from Mikael Olenfalk.
I learned using string interpolation where I can ctrl+space (intellisense) and use resource references. However I am unsure if this is always required (to reference resources in my *.tf file)? If I dont need to interpolate but only reference a resource, using the "string-interpolation-way" is really noisy.
Lets say I have a azurerm_storage_account resource of the name static-site. I can do the following and vs code says all is okay.
name = "${azurerm_storage_account.static-site.name}"
or I can do this
name = azurerm_storage_account.static-site.name
and I am getting an error unexpected token while parsing list: IDENT
By contrast if I look around on the official docs site, there is clearly some cases where quotes are not used, e.g. see the example in this section https://www.terraform.io/docs/configuration/resources.html#depends_on-explicit-resource-dependencies
resource "aws_iam_role_policy" "example" {
name = "example"
role = aws_iam_role.example.name
policy = jsonencode({
"Statement" = [{
# This policy allows software running on the EC2 instance to
# access the S3 API.
"Action" = "s3:*",
"Effect" = "Allow",
}],
})
}
resource "aws_instance" "example" {
ami = "ami-a1b2c3d4"
instance_type = "t2.micro"
iam_instance_profile = aws_iam_instance_profile.example <--------------- !!!
# However, if software running in this EC2 instance needs access
# to the S3 API in order to boot properly, there is also a "hidden"
# dependency on the aws_iam_role_policy that Terraform cannot
# automatically infer, so it must be declared explicitly:
depends_on = [
aws_iam_role_policy.example,
]
}
Which would give errors for me. Or is this especially required for azure resources (which I use)? The example above was with aws.
Cheers