Reputation: 2973
I stuck at old code written by another developer 2 years before, that I can't pass the terraform validate
. I tried validate with old terrafrom version as well, 0.11, 0.13, 0.15 and 1.0
variable "aws_name" {
default = "${aws:name}"
}
I am confused by the sytax, that looks the author try to reference variable from another variable in terraform, but I don't think terraform supports this feature, from beginning.
I mean no support by this way from old versions, such as terrafrom 0.6, to current version 1.0.x
If the code use ${var.xxxx}
, I think it was the code created before terraform 0.12, because after that, we don't need "${ }"
to reference a variable, we can directly reference it via var.aws_name
Second we can't reference a variable as "aws:name" without "var" in front of it, and colon will misleading in terraform as well.
Any one knew this way in terraform, is it validated in some of terrafrom versions?
As @Matt Schuchard mentioned, the azure pipeline task replacetokens@4
does support other style for the replacement (the fourth)
Upvotes: 1
Views: 571
Reputation: 238081
try to reference variable from another variable in terraform, but I don't think terraform supports this feature
That's correct. You can't do this. The only reason for that I can think of is that the terraform was part of some CI/CD pipeline. Thus, maybe before the actual TF scripts were run, they were per-processed by an external tool, which made simple find-and-replace of ${aws:name}
string to valid values.
One possibility could be Before Hooks in terragrunt.
Upvotes: 3