LoginSignup
21
8

More than 3 years have passed since last update.

Terraformで警告エラー「Warning: Interpolation-only expressions are deprecated」

Last updated at Posted at 2020-01-11

terraform-eyecatch.png

概要

以下の記事を参考にTerraformでIAMユーザ作っていたら警告エラーが出たのでメモ

TerraformでIAMグループ・ユーザを作成する
https://qiita.com/digitalpeak/items/427f6cf7ed14f4187cd2

事象

Terraformでplanを実行したら以下のような警告エラーが出た

Warning: Interpolation-only expressions are deprecated

  on iam_user.tf line 2, in resource "aws_iam_user" "example_exp":
   2:   count         = "${length(var.aws_iam_user)}"

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.

よくわからないのでGoogle翻訳にぶち込んでみる

警告:補間のみの式は、リソース「aws_iam_user」「example_exp」のiam_user.tf行2で非推奨です:2:count = "$ {length(var.aws_iam_user)}" Terraform 0.11以前では、非定数式が補間構文を介して提供されますが、このパターンは非推奨になりました。

この警告を黙らせるには、この式の最後から「$ {シーケンスを開始し、}」シーケンスを削除して、内側の式のみを残します。テンプレートに複数の補間シーケンス、またはリテラル文字列と補間の混合が含まれている場合、式から文字列を構築するためにテンプレート補間構文が引き続き使用されます。この非推奨は、完全に単一の補間シーケンスで構成されるテンプレートにのみ適用されます。 (および他の同様の警告)

なるほど、今インストールしているバージョンで、以下の書き方が古い臭いですって怒られているみたい。

2:count = "$ {length(var.aws_iam_user)}"

解消方法

バインドの書き方を変えたら直った!

2:count = length(var.aws_iam_user)
21
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
8