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

On plan, redrive_policy is always marked as modified #1177

Closed
hashibot opened this issue Jul 18, 2017 · 3 comments
Closed

On plan, redrive_policy is always marked as modified #1177

hashibot opened this issue Jul 18, 2017 · 3 comments
Labels
bug Addresses a defect in current functionality. service/sqs Issues and PRs that pertain to the sqs service.

Comments

@hashibot
Copy link

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 Version

Terraform v0.9.8

Expected Behaviour

That no change is detected for the redrive policies, since no change has been made.

Actual Behaviour

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

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  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

References

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.

@apparentlymart apparentlymart added the bug Addresses a defect in current functionality. label Jul 18, 2017
@bflad bflad added the service/sqs Issues and PRs that pertain to the sqs service. label Jan 28, 2018
@bflad
Copy link
Contributor

bflad commented Jan 28, 2018

@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

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Jan 28, 2018
@bflad
Copy link
Contributor

bflad commented May 31, 2018

Closing due to lack of response and a proposed solution above.

@bflad bflad closed this as completed May 31, 2018
@zfael
Copy link

zfael commented May 31, 2019

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

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label May 31, 2019
@hashicorp hashicorp locked as resolved and limited conversation to collaborators Jun 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/sqs Issues and PRs that pertain to the sqs service.
Projects
None yet
Development

No branches or pull requests

4 participants