I finally figured this out: it’s caller (sender or receiver). While the caller doesn’t call KMS directly, SQS does so with their permissions when sending/receiving (and it never uses it’s own “Service” permissions for anything to do with encryption).
The default aws/sqs KMS key policy is
{
“Version”: “2012-10-17”,
“Id”: “auto-sqs-1”,
“Statement”: [
{
“Sid”: “Allow access through Simple Queue Service (SQS) for all principals in the account that are authorized to use SQS”,
“Effect”: “Allow”,
“Principal”: {
“AWS”: “"
},
“Action”: [
“kms:Encrypt”,
“kms:Decrypt”,
"kms:ReEncrypt”,
“kms:GenerateDataKey*”,
“kms:CreateGrant”,
“kms:DescribeKey”
],
“Resource”: “",
“Condition”: {
“StringEquals”: {
“kms:ViaService”: “sqs.us-east-1.amazonaws.com”,
“kms:CallerAccount”: “853263162156”
}
}
},
{
“Sid”: “Allow direct access to key metadata to the account”,
“Effect”: “Allow”,
“Principal”: {
“AWS”: “arn:aws:iam::<account_id>:root”
},
“Action”: [
"kms:Describe”,
“kms:Get*”,
“kms:List*”,
“kms:RevokeGrant”
],
“Resource”: “*”
}
]
}
So if you want SNS to publish (which has no kms:CallerAccount), you have to create a custom KMS key. A generic policy would be:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "kms:*",
"Resource": "*",
"Condition": {
"StringEquals": {
"kms:ViaService": "sqs.us-east-1.amazonaws.com"
}
}
},
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<account_id>:root"
},
"Action": "kms:*",
"Resource": "*"
}
]
}
This allows anyone SQS thinks should encrypt to encrypt.
The only downside with this generic policy that it allows anyone who knows your key id to use it for their own SQS queues (causing a billing problem, not a confidentiality problem).
If you wanted to more exact, you’d basically just have to repeat the same thing you use for your sqs:SendMessage resource-based and identity-based policies.
For SNS, I believe the caller needs Encrypt permissions and the SNS service needs decrypt permissions.