修复“仅插值表达式已弃用";Terraform 中的警告 [英] Fix "Interpolation-only expressions are deprecated" warning in Terraform

查看:18
本文介绍了修复“仅插值表达式已弃用";Terraform 中的警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I upgraded to Terraform v0.12.16 and now I am getting a lot of messages that look like this:

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.

有数百条这样的消息.是否有自动修复它们的方法?

There are hundreds of these messages. Is there an automated way to fix them?

推荐答案

此工具会自动为您去除开头和结尾的引号和大括号,从而修复警告:https://github.com/apparentlymart/terraform-clean-syntax

This tool will automatically strip the beginning and ending quotes and braces for you, which fixes the warnings: https://github.com/apparentlymart/terraform-clean-syntax

go get github.com/apparentlymart/terraform-clean-syntax
terraform-clean-syntax .

这篇关于修复“仅插值表达式已弃用";Terraform 中的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆