Terraform-provider-aws: 計画では、redrive_policyは常に変更済みとしてマークされます

作成日 2017年07月18日  ·  3コメント  ·  ソース: hashicorp/terraform-provider-aws

_この問題は、もともと@kfrnによってhashicorp / terraform#15579として開かれました。 プロバイダー分割の結果、ここに移行されました。 問題の元の本文は以下のとおりです。_


terraform planを実行するたびに、SQSキューのリドライブポリシーは、実際には変更されていなくても、変更されたものとして表示されます。

モジュールを使用してSQSキューを作成しています。

resource "aws_sqs_queue" "sqs_queue" {
  name                       = "${var.environment}_${var.name}"
  message_retention_seconds  = "${var.sqs_queue["message_retention_seconds"]}"
  visibility_timeout_seconds = "${var.sqs_queue["visibility_timeout_seconds"]}"

  redrive_policy = <<-JSON
    {
      "deadLetterTargetArn": "${aws_sqs_queue.sqs_dead_queue.arn}",
      "maxReceiveCount": "${var.sqs_queue["max_receive_count"]}"
    }
  JSON
}

resource "aws_sqs_queue" "sqs_dead_queue" {
  name                       = "${var.environment}_${var.name}_dead"
  message_retention_seconds  = "${var.sqs_dead_queue["message_retention_seconds"]}"
  visibility_timeout_seconds = "${var.sqs_dead_queue["visibility_timeout_seconds"]}"
}

maxReceiveCountはモジュール変数に設定されます:

variable "sqs_queue" {
  type = "map"

  default = {
    message_retention_seconds  = 1209600
    visibility_timeout_seconds = 30
    max_receive_count          = 10
  }
}

Terraformバージョン

Terraform v0.9.8

期待される動作

変更が行われていないため、リドライブポリシーの変更は検出されません。

実際の動作

screen shot 2017-07-18 at 4 39 38 pm

再現する手順

問題を再現するために必要な手順をリストしてください。次に例を示します。

  1. terraform get
  2. terraform plan -var-file=<var-file>.tfvars -out=<my-update>.plan -state=<current-state-file>.tfstate
  3. terraform apply -state-out=<new-state-file>.tfstate <my-update>.plan

参考文献

この問題は2016年2月にここで議論されました:hashicorp / terraform#5119
その人のコードのmaxReceiveCountが数字ではなく文字列だったためだと思われます。 その後、バグはパッチ(#5888)を獲得しました。
だから私はなぜこれが私のために起こっているのか本当にわかりません。 ちなみに、私のmaxReceiveCountは間違いなく整数です。

bug servicsqs

最も参考になるコメント

@kfrnここで問題を理解しましたか?

上記の構成では、 "${var.sqs_queue["max_receive_count"]}"ます。 JSONヒアドキュメント内の引用符は無関係であり、この場合、変数補間を取得するためにTerraformの構成で必要とされないため、JSONは次のようになります。

redrive_policy = <<-JSON
    {
      "deadLetterTargetArn": "${aws_sqs_queue.sqs_dead_queue.arn}",
      "maxReceiveCount": ${var.sqs_queue["max_receive_count"]}
    }
  JSON

全てのコメント3件

@kfrnここで問題を理解しましたか?

上記の構成では、 "${var.sqs_queue["max_receive_count"]}"ます。 JSONヒアドキュメント内の引用符は無関係であり、この場合、変数補間を取得するためにTerraformの構成で必要とされないため、JSONは次のようになります。

redrive_policy = <<-JSON
    {
      "deadLetterTargetArn": "${aws_sqs_queue.sqs_dead_queue.arn}",
      "maxReceiveCount": ${var.sqs_queue["max_receive_count"]}
    }
  JSON

応答の欠如と上記の提案された解決策のために終了します。

これについてのフォローアップです。
私は同じ問題に直面していて、 ${var.sqs_queue["max_receive_count"]の無関係な引用符を削除すると問題が修正されました

ありがとう@bflad

このページは役に立ちましたか?
0 / 5 - 0 評価