mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-18 20:52:58 -06:00
91752f02da
Following on from de652e22a26b, this introduces deprecation warnings for when an attribute value expression is a template with only a single interpolation sequence, and for variable type constraints given in quotes. As with the previous commit, we allowed these deprecated forms with no warning for a few releases after v0.12.0 to ensure that folks who need to write cross-compatible modules for a while during upgrading would be able to do so, but we're now marking these as explicitly deprecated to guide users towards the new idiomatic forms. The "terraform 0.12upgrade" tool would've already updated configurations to not hit these warnings for those who had pre-existing configurations written for Terraform 0.11. The main target audience for these warnings are newcomers to Terraform who are learning from existing examples already published in various spots on the wider internet that may be showing older Terraform syntax, since those folks will not be running their configurations through the upgrade tool. These warnings will hopefully guide them towards modern Terraform usage during their initial experimentation, and thus reduce the chances of inadvertently adopting the less-readable legacy usage patterns in greenfield projects.
37 lines
1.3 KiB
HCL
37 lines
1.3 KiB
HCL
# It's redundant to write an expression that is just a single template
|
|
# interpolation with another expression inside, like "${foo}", but it
|
|
# was required before Terraform v0.12 and so there are lots of existing
|
|
# examples out there using that style.
|
|
#
|
|
# We are generating warnings for that situation in order to guide those
|
|
# who are following old examples toward the new idiom.
|
|
|
|
variable "triggers" {
|
|
type = "map" # WARNING: Quoted type constraints are deprecated
|
|
}
|
|
|
|
provider "null" {
|
|
foo = "${var.triggers["foo"]}" # WARNING: Interpolation-only expressions are deprecated
|
|
}
|
|
|
|
resource "null_resource" "a" {
|
|
triggers = "${var.triggers}" # WARNING: Interpolation-only expressions are deprecated
|
|
|
|
connection {
|
|
type = "ssh"
|
|
host = "${var.triggers["host"]}" # WARNING: Interpolation-only expressions are deprecated
|
|
}
|
|
|
|
provisioner "local-exec" {
|
|
single = "${var.triggers["greeting"]}" # WARNING: Interpolation-only expressions are deprecated
|
|
|
|
# No warning for this one, because there's more than just one interpolation
|
|
# in the template.
|
|
template = " ${var.triggers["greeting"]} "
|
|
|
|
# No warning for this one, because it's embedded inside a more complex
|
|
# expression and our check is only for direct assignment to attributes.
|
|
wrapped = ["${var.triggers["greeting"]}"]
|
|
}
|
|
}
|