-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Multiple aws_sqs_queue_policy adds only one policy to queue #12003
Comments
This same behavior exists within the Policy vs. PermissionThe SQS developer guide states the following in regards to SQS policies:
That is to say, if you want to apply an SQS queue policy with multiple statements, they should reside within a single policy container. For example:
The distinction becomes even clearer when you examine the documentation for the
Terraform is calling the Actual Terraform BehaviorA test like the one you provided above shows that Terraform actually overwrites the first policy with the second policy. Here is a simplified SQS test that produces the behavior in question. For each of the The simplest way to prove this is by first creating an SQS queue with a single
The queue policy looks like we expect; note the policy
Now if we add a second
When we run an apply, Terraform overwrites the SQS queue policy with the second one. Here is the new SQS queue policy, note the policy
Possible Fixes
@grubernaut I'm happy to update the documentation if you agree with that approach? |
For anyone looking for a temporary workaround, you can use an inline policy with Here's what we have: resource "aws_sqs_queue_policy" "sns_to_sqs" {
queue_url = "${var.queue_url}"
policy = <<POLICY
{
"Version": "2012-10-17",
"Id": "sqspolicy",
"Statement": [
{
"Sid": "First",
"Effect": "Allow",
"Principal": "*",
"Action": "sqs:SendMessage",
"Resource": "${var.queue_arn}",
"Condition": {
"ArnEquals": {
"aws:SourceArn": ${jsonencode(var.topic_arns)}
}
}
}
]
}
POLICY
} |
@bosgood This worker well for me. Any fix for this so far? |
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. |
Terraform Version
v0.8.7
Affected Resource(s)
Please list the resources as a list, for example:
Terraform Configuration Files
Expected Behavior
Should have created two separate policies.
Actual Behavior
Created only one policy attached to the queue.
In each
plan
TF would like to modify the policies and duringapply
it applies them successfully.Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform plan
terraform apply
terraform plan
Important Factoids
N/A
References
N/A
The text was updated successfully, but these errors were encountered: