Hi,
I'm trying to conditionally deny sqs:SendMessage on an SQS queue based on a resource tag.
My goal is to “suspend” a queue by adding a tag like suspend=true, and have a resource-based queue policy deny SendMessage when that tag is present.
Here is the queue policy I'm trying to apply:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Principal": "*",
"Action": "sqs:SendMessage",
"Resource": "arn:aws:sqs:us-east-2:123456789012:TestQueue",
"Condition": {
"StringEquals": {
"aws:ResourceTag/suspend": "true"
}
}
}
]
}
When I apply this policy (via CDK / SetQueueAttributes and via the console), I get the following error:
InvalidParameterValueException: Value aws:ResourceTag/suspend for parameter Condition is invalid.
Reason: Conditions must be from Global context key list
However, according to the Service Authorization Reference for SQS, [aws:ResourceTag/${TagKey} appears to be a valid condition key for SQS]resources(https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonsqs.html#amazonsqs-policy-keys:~:text=String-,aws%3AResourceTag/%24%7BTagKey%7D,-Filters%20access%20by)
My questions:
Is aws:ResourceTag/... supported in SQS resource-based queue policies? If not, it seems that the documentation is misleading.
What is the recommended way to implement a “temporary suspension” of SendMessage without deleting/recreating the queue?
For context:
- The queue is in a single AWS account
- The tag exists on the queue
- ABAC for SQS is supported in this region (us-east-2)
- The policy is attached directly to the queue
Thanks in advance for any clarification.
Oh, ok, I see. Thanks for you answer. I was not aware there was a breakdown of Condition Keys available by Actions (which https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonsqs.html)