_This issue was originally opened by @kfrn as hashicorp/terraform#15579. It was migrated here as a result of the provider split. The original body of the issue is below._
Every time I run terraform plan
, the redrive policies for my SQS queues show up as modified, even though they actually have no changes.
I'm using a module to create my SQS queues.
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
is set in the module variables:
variable "sqs_queue" {
type = "map"
default = {
message_retention_seconds = 1209600
visibility_timeout_seconds = 30
max_receive_count = 10
}
}
Terraform v0.9.8
That no change is detected for the redrive policies, since no change has been made.
Please list the steps required to reproduce the issue, for example:
terraform get
terraform plan -var-file=<var-file>.tfvars -out=<my-update>.plan -state=<current-state-file>.tfstate
terraform apply -state-out=<new-state-file>.tfstate <my-update>.plan
This problem was discussed in February 2016, here: hashicorp/terraform#5119
It seems to have been because the maxReceiveCount
in that person's code was a string, not a number; the bug then garnered a patch (#5888).
So I'm really unsure why this is happening for me. For the record, my maxReceiveCount
is definitely an integer.
@kfrn did you figure out the problem here?
In your configuration above, you have "${var.sqs_queue["max_receive_count"]}"
. The quotes inside the JSON heredoc are extraneous and not required by Terraform's configuration to pick up the variable interpolation in this case, so your JSON can look like:
redrive_policy = <<-JSON
{
"deadLetterTargetArn": "${aws_sqs_queue.sqs_dead_queue.arn}",
"maxReceiveCount": ${var.sqs_queue["max_receive_count"]}
}
JSON
Closing due to lack of response and a proposed solution above.
Just a follow-up on this.
I was facing the same issue and removing the extraneous quotes on ${var.sqs_queue["max_receive_count"]
fixed the issue
thanks @bflad
Most helpful comment
@kfrn did you figure out the problem here?
In your configuration above, you have
"${var.sqs_queue["max_receive_count"]}"
. The quotes inside the JSON heredoc are extraneous and not required by Terraform's configuration to pick up the variable interpolation in this case, so your JSON can look like: