修复 Terraform 中的“仅插值表达式已被弃用”警告

2024-01-06

我升级到 Terraform v0.12.16,现在我收到很多类似这样的消息:

Warning: Interpolation-only expressions are deprecated

  on ../modules/test-notifier/test_notifier.tf line 27, in resource "aws_sns_topic_policy" "default":
  27:   arn    = "${aws_sns_topic.default.arn}"

Terraform 0.11 and earlier required all non-constant expressions to be
provided via interpolation syntax, but this pattern is now deprecated. To
silence this warning, remove the "${ sequence from the start and the }"
sequence from the end of this expression, leaving just the inner expression.

Template interpolation syntax is still used to construct strings from
expressions when the template includes multiple interpolation sequences or a
mixture of literal strings and interpolations. This deprecation applies only
to templates that consist entirely of a single interpolation sequence.

这些消息有数百条。有没有一种自动化的方法来修复它们?


  Warning: Interpolation-only expressions are deprecated

  on main.tf line 3, in provider "aws":
   3:   region  = "${var.region}"

我还收到了上述警告,这是由于在 terraform 中声明变量的语法发生了变化。 请参阅下面的示例 -:

旧语法-region = "${var.region}" # 你会得到 Interpolation-only 警告

新语法-region = var.region # 无警告

检查语法并使用任何代码编辑器更正它。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

修复 Terraform 中的“仅插值表达式已被弃用”警告 的相关文章

随机推荐