AWS SQS 在 cli 上发送带有 KMS ID 的消息

AWS SQS send message with KMS ID on cli

我有一个使用 KMS 客户主密钥 (CMK) 加密的 SQS 队列

在使用 send-message cli 命令时,我无法获得 --message-attributes 正确添加 KMS 密钥 ID 的语法

aws sqs send-message --queue-url "queue/url" --message-body "testing" --message-attributes '{"keyId": {"DataType":"String", "StringValue":"mKeyId"}}'

我得到的错误是

An error occurred (KMS.NotFoundException) when calling the SendMessage operation: Invalid keyId (Service: AWSKMS; Status Code: 400; Error Code: NotFoundException; Request ID: 02cae15e-bf78-11e7-c001-f9dff348cb7e)

密钥是正确的密钥,我也尝试过使用密钥别名。

SQS docs

中找不到任何内容

我的语法出了什么问题?

原来我通过 cloudformation 创建了一个错误的队列

在阅读 SQS 的 Cloudformation 文档时,KmsMasterKeyId 我已经包含了我的 CMK 别名,而您只应在使用 AWS 托管 sse 时使用别名 (/alias/aws/sqs)。

当更新到我的实际密钥 ID 时,我使用的 cli 命令工作得很好

aws sqs send-message --queue-url "queue/url" --message-body "testing" --message-attributes '{"keyId": {"DataType":"String", "StringValue":"mKeyId"}}'