terraform-provider-aws: aws_sqs_queue_policy - fails on first apply, succeeds on second apply with no changes

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave “+1” or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

0.12.28

Affected Resource(s)

  • aws_sqs_queue_policy

Terraform Configuration Files

resource "aws_sqs_queue_policy" "deadletter_queue" {
  queue_url = aws_sqs_queue.deadletter_queue.id
  policy    = data.aws_iam_policy_document.deadletter_queue.json
}

data "aws_iam_policy_document" "deadletter_queue" {
  statement {
    effect    = "Allow"
    resources = [aws_sqs_queue.deadletter_queue.arn]
    actions = [
      "sqs:ChangeMessageVisibility",
      "sqs:DeleteMessage",
      "sqs:GetQueueAttributes",
      "sqs:GetQueueUrl",
      "sqs:ListQueueTags",
      "sqs:ReceiveMessage",
      "sqs:SendMessage",
    ]
    principals {
      type        = "AWS"
      identifiers = [var.allowed_arn]
    }
  }

Debug Output

Error: Error updating SQS attributes: InvalidAttributeValue: Invalid value for the parameter Policy.
	status code: 400, request id: 30b6f60c-a403-5af4-8fdb-a178a4dda18f

  on modules/sqs/main.tf line 54, in resource "aws_sqs_queue_policy" "deadletter_queue":
  54: resource "aws_sqs_queue_policy" "deadletter_queue" {

Expected Behavior

Terraform should create the resource on the first apply

Actual Behavior

Terraform fails with the error above, on a re-run with no changes the apply succeeds.

Steps to Reproduce

  1. terraform apply
  2. terraform fails
  3. terraform apply
  4. terraform succeeds

Important Factoids

Happens on both CI and local machine

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 26
  • Comments: 16 (1 by maintainers)

Commits related to this issue

Most upvoted comments

This is resolved

On Fri, Dec 11, 2020 at 5:45 PM Natan Lao notifications@github.com wrote:

I can reproduce this:

(.venv) ~/u/c/terraform develop> terraform -version Terraform v0.14.0

  • provider registry.terraform.io/hashicorp/archive v2.0.0
  • provider registry.terraform.io/hashicorp/aws v3.20.0
  • provider registry.terraform.io/hashicorp/local v2.0.0

Your version of Terraform is out of date! The latest version is 0.14.2. You can update by downloading from https://www.terraform.io/downloads.html

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hashicorp/terraform-provider-aws/issues/13980#issuecomment-743484497, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM7XD4QALKXZ6GTJ2MDV2GDSUKVK3ANCNFSM4OLKCWSA .

– Thanks, Rex

This seems to be still an issue. I am facing the same problem even with a 0.14.4

@rexxavier could you elaborate? thank you