Lambda SNS KMS Encryption Permissions
Short answer
ACD Create an SNS resource policy allowing Lambda (A, D) and a KMS key policy allowing SNS to use the CMK (C).
Question
Key Takeaways
The common trap is assuming that because SNS manages encryption, the publisher does not need KMS permissions; however, with CMKs, explicit permissions in the KMS key policy are required for the SNS service to encrypt on behalf of the publisher.
This question tests the necessary IAM and resource policies for a Lambda function publishing encrypted messages to an Amazon SNS topic using a Customer Managed Key (CMK). The correct configuration requires both an SNS topic policy granting publish access and a KMS key policy allowing SNS to use the encryption key.
Common mistake: Many candidates select D instead of C, believing that specifying the Lambda ARN in the SNS policy is sufficient. This overlooks the fact that without KMS permissions, the SNS topic cannot actually encrypt the payload using the specified CMK.
Expert Analysis
Why the Answer Is Correct
To securely publish PHI to an encrypted SNS topic, two distinct permission layers must be configured. First, the SNS topic itself must allow the Lambda function to send messages; this is achieved by creating a resource policy on the SNS topic (Option A) that explicitly specifies the Lambda function's ARN (Option D). Second, because the topic uses a Customer Managed Key (CMK), the SNS service needs permission to use that key for encryption. AWS documentation states that you must add permissions to the KMS key policy to allow Amazon SNS to encrypt and decrypt messages (Option C). Without these KMS permissions, the publish operation will fail or result in unencrypted data depending on configuration, violating security requirements.
Why the Other Options Are Wrong
Option B suggests switching to SSE-KMS with AWS-managed keys, but the requirement specifies using customer managed keys, making this irrelevant. Option E introduces API Gateway, which is unnecessary complexity and not part of the direct Lambda-to-SNS invocation path described. Option D alone is insufficient because it grants SNS access but fails to grant the underlying KMS service permission to perform the cryptographic operations required by the CMK setup.
Community Comment Notes
Community consensus heavily favors AC, with several users noting that while D is technically part of the SNS policy setup, the critical missing piece often missed is the KMS key policy (C). One user noted 'D is correct too and С is not clear', highlighting confusion about whether SNS handles encryption internally. Another user correctly pointed out that 'If using a custom KMS key, include the following in the key policy to allow Amazon SNS to encrypt'. The debate often centers on whether D is a separate step or part of A; in exam logic, A describes the action of creating the policy, and D describes the content, but C is the distinct third requirement for CMKs.
Official Reference
- https://docs.aws.amazon.com/sns/latest/dg/sns-enable-encryption-for-topic.html
- https://docs.aws.amazon.com/kms/latest/developerguide/allow-use-key.html
These links open the official vendor documentation in a new tab.
Exam Strategy
When dealing with encrypted services using CMKs, always check if the consuming service (like SNS) needs explicit permissions in the KMS key policy to encrypt/decrypt. Do not assume the service handles all crypto automatically when a CMK is involved.
Frequently Asked Questions
Why does Lambda need KMS permissions if SNS encrypts?
Is specifying the Lambda ARN in the SNS policy enough?
Discussion 10 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 10
-
elmyth 👍 4D is correct too and С is not clear, but seems like it is about KMS policy and adding permissions for sns service which has to be added in case of CMK
-
EllenLiu 👍 2I don't understand why lambda needs KMS to encrypt message. In this scenario, the Lambda function does not need direct permissions to use the KMS key because the encryption and decryption are fully managed by Amazon SNS as part of the SSE-KMS feature. SNS is the only service lambda will talk to, The Lambda interacts with SNS using HTTPS and does not directly deal with the encrypted data or the KMS key. so Lambda only needs the permission to publish messages to the SNS topic. I would like to choose F only if #F answer can be updated as below: F. Configure a Lambda execution role that has the necessary IAM permissions to publish to the SNS topic. A: Create a resource policy for the SNS topic => grants lambda the ability to publish messages to the topic C: The KMS key resource policy must allow SNS to use the key for encryption and decryption. F: Configure the Lambda Execution Role => SNS permissions to publish to the topic
-
LeonSauveterre 👍 2A - This is a must-do. B - As question stated, we have no reason to replace the keys. C - This ensures the function can encrypt messages when publishing. D - While specifying the Lambda function's ARN in the SNS topic's resource policy is part of the solution (it's how you grant the "sns:Publish" permission), it's not sufficient on its own. You also need the KMS key policy and the Lambda execution role permissions. This option is a part of option A, not a standalone answer. E - The Lambda function interacts directly with the SNS topic, and API Gateway is not relevant. F - Yes, so that this role will have policies that allow the "kms:Encrypt", "kms:GenerateDataKey," and "kms:Decrypt" actions on the specific KMS key used to encrypt the topic.
-
JA2018 👍 2#A: This is essential because the resource policy on the SNS topic will define which entities (like the Lambda function) are allowed to publish messages to it. #D: By specifying the Lambda function's ARN in the SNS topic policy, you clearly grant access only to that specific Lambda function. #F: Since the SNS topic uses a customer-managed KMS key, the Lambda execution role must have the necessary permissions to use that key for encryption/decryption when publishing messages.
-
GOTJ 👍 1Does a SNS topic need to decrypt an encrypted message in order to deliver it to its subscribers? If so, option "C" should be in. If not, it should be out. And I think is out, unless SNS topic needs to apply certain logic to the message prior to subscription deliver (filters). This question requires a CSE-KMS approach, which force the Lambda function to encrypt the message before publishing, so option "F" is a must (I think everybody here is on the same page with this one). Also, option "A" should be obvious by now. And even though option "D" is redundant, it's technically correct, so it's a better choice.
Show 5 more comments
-
FlyingHawk 👍 1For C - https://docs.aws.amazon.com/sns/latest/dg/sns-enable-encryption-for-topic.html Permissions for custom KMS keys – If using a custom KMS key, include the following in the key policy to allow Amazon SNS to encrypt and decrypt messages:
-
Abbas_Abi_AWS 👍 8A C F is corrcet
-
komorebi 👍 4Answer is ADF
-
progounick 👍 3ChatGPT agrees with me
-
agbor_tambe 👍 1my answer
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.
Related Analysis
Practice All SAA-C03 Questions
Access 120 questions with complete answers and detailed explanations.
View Full SAA-C03 Practice Test →