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

provider/aws: SQS use raw policy string if compact fails #6724

Merged
merged 1 commit into from
May 24, 2016

Conversation

catsby
Copy link
Contributor

@catsby catsby commented May 17, 2016

In a complicated policy setup, the initial json.Compact may fail if the policy uses the lookup interpolation function in Terraform.

Given this (snippet):

variable "aws_region" {
  default = "us-west-2"
}

variable "devs" {
  default = "atlas-terraform-acctests,clint"
}

variable "aws_accts" {
  type = "map"

  default = {
    development = "***"
    management  = "***"
  }
}

resource "aws_sqs_queue" "queue" {
  name  = "${element(split(",", var.devs), count.index)}-queue"
  count = "${length(split(",", var.devs))}"

  policy = <<EOF
{
  "Version": "2012-10-17",
  "Id": "arn:aws:sqs:${var.aws_region}:${lookup(var.aws_accts, "development")}:${element(split(",", var.devs), count.index)}-queue/SQSDefaultPolicy",
  "Statement": [
    {
  [...]
}
EOF
}

The policy attribute of aws_sqs_queue calls json.Compact on the value, however due to the lookup call with " in it, the compaction will fail on the first run if the aws_sqs_queue source does not yet exist (it's in the plan as well). Right now, a plan->apply will result in a diffs don't match error. A second run will apply successfully because the interpolations will succeed.

Here, if the initial json.Compact fails, we simply use the raw string.

Fixes #6705

@stack72
Copy link
Contributor

stack72 commented May 19, 2016

LGTM! Nice work :)

@phinze
Copy link
Contributor

phinze commented May 23, 2016

LGTM 👍

@catsby catsby merged commit 171c1e3 into master May 24, 2016
@catsby catsby deleted the b-aws-sqs-compact-fix branch May 24, 2016 15:38
@ghost
Copy link

ghost commented Apr 25, 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 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Getting "diffs didn't match during apply" when creating SQS Queues
3 participants