title: Terraform - Each statement in the policy should have exactly one resource
body: <p>I have an <code>aws_iam_policy_document</code> that Im trying to attach to multiple queues. The policy document looks like this:</p>
  
  <pre><code>data "aws_iam_policy_document" "my_policy" {
    statement {
      principals {
        type        = "*"
        identifiers = ["*"]
      }
  
      actions = [
        "sqs:SendMessage"
      ]
  
      resources = [
        "${aws_sqs_queue.q1.arn}",
        "${aws_sqs_queue.q2.arn}",
        "...",
        "${aws_sqs_queue.q8.arn}"
      ]
  
      condition {
        test = "ArnEquals"
        variable = "aws:SourceArn"
        values = [
          "${aws_sns_topic.sns_topic_name.arn}"
        ]
      }
    }
  }
  </code></pre>
  
  <p>When I run terraform plan it does not show any error. However running terraform apply I get : <code>Policy is invalid. Reason: Each statement in the policy should have exactly one resource</code> . Is there a way I can put in a variable for the resource name which gets substituted with the name of the queue when being attached to said queue ?</p>
  
  <p>This is how my queue and queue policy looks like:</p>
  
  <pre><code>resource "aws_sqs_queue" "queue_name" {
      name                       = "queue_name_${var.environment}"
      visibility_timeout_seconds = 30
      message_retention_seconds  = 345600
      max_message_size           = 262144
      delay_seconds              = 0
      receive_wait_time_seconds  = 0
  }
  
  
  resource "aws_sqs_queue_policy" "queue_name_policy" {
    queue_url = "${aws_sqs_queue.queue_name.id}"
    policy    = "${data.aws_iam_policy_document.my_policy.json}"
  }
  </code></pre>