Each time I run terraform plan without changing anything about the aws_sqs_queue resource, it always shows the redrive_policy field as modified. Upon review, I can see the changes it shows are only related to white space (new lines).
Given:
resource "aws_sqs_queue" "my_queue" {
name = "my_queue"
delay_seconds = 0
visibility_timeout_seconds = 300
redrive_policy = <<EOF
{
"maxReceiveCount": "3",
"deadLetterTargetArn": "${aws_sqs_queue.my_dead_letter_queue.arn}"
}
EOF
}
resource "aws_sqs_queue" "my_dead_letter_queue" {
name = "my_dead_letter_queue"
}
Running terraform apply and then terraform plan yields changes. I expect it to yield no changes.
~ aws_sqs_queue.audit_queue
redrive_policy: "{\"deadLetterTargetArn\":\"arn:aws:sqs:us-east-1:1234:my-dead-letter-queue\",\"maxReceiveCount\":3}" => "{\n \"maxReceiveCount\": \"3\",\n \"my-deadLetterTargetArn\": \"arn:aws:sqs:us-east-1:123:dead-letter-queue\"\n}\n"
:+1: seeing the same thing
resource "template_file" "my_redrive_policy" {
template = "${file("${path.module}/sqs_redrive_policy.json.tpl")}"
vars {
max_receive_count = "10"
target_arn = "${aws_sqs_queue.my_dead_queue.arn}"
}
}
resource "aws_sqs_queue" "my_queue" {
name = "sender-${var.environment_name}"
redrive_policy = "${template_file.my_redrive_policy.rendered}"
}
sqs_redrive_policy.json.tpl
{
"maxReceiveCount": "${max_receive_count}",
"deadLetterTargetArn": "${target_arn}"
}
the order of 'maxReceiveCount' & 'deadLetterTargetArn' in the rendered redrive policy template keep switching on planning.
Same here, Terraform v0.6.12.
Hey Friends –
I've opened https://github.com/hashicorp/terraform/pull/5888 to patch this. It's 1 part code fix, one part documentation; the maxReceiveCount needs to be an integer, not a string, so:
redrive_policy = <<EOF
{
"maxReceiveCount": 3,
"deadLetterTargetArn": "${aws_sqs_queue.my_dead_letter_queue.arn}"
}
EOF
}
Unfortunately, because this is a JSON I can't immediately inspect it and format automatically, so you'll need to make that correction.
@catsby How do you pass integer if we were to set maxReceiveCount via terraform.tfvars ?
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.