Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource aws_sqs_queue.redrive shows changes when there are no changes #5119

Closed
conorgil opened this issue Feb 13, 2016 · 5 comments · Fixed by #5888
Closed

Resource aws_sqs_queue.redrive shows changes when there are no changes #5119

conorgil opened this issue Feb 13, 2016 · 5 comments · Fixed by #5888

Comments

@conorgil
Copy link

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"
@AlexWiles
Copy link

👍 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.

@ghost
Copy link

ghost commented Mar 9, 2016

Same here, Terraform v0.6.12.

@catsby
Copy link
Contributor

catsby commented Mar 28, 2016

Hey Friends –

I've opened #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.

@yasin-amadmia-mck
Copy link

@catsby How do you pass integer if we were to set maxReceiveCount via terraform.tfvars ?

@ghost
Copy link

ghost commented Apr 22, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants