For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/cloudformation-aws-sns-topic-without-kms-master-key-id.md.
A documentation index is available at /llms.txt.
SNS topics should use a customer-managed AWS KMS key for server-side encryption to protect published messages at rest and to enable controllable key access, rotation, and auditability.
In CloudFormation, AWS::SNS::Topic resources must define Properties.KmsMasterKeyId and set it to a KMS key identifier (key ARN, key ID, alias such as alias/your-alias, or a Ref/Fn::GetAtt to an AWS::KMS::Key). Resources missing this property will be flagged. When KmsMasterKeyId is undefined, SNS falls back to the AWS-managed key (aws/sns), which you cannot fully manage via custom key policies or rotation and which may not meet compliance or cross-account access requirements.
Secure configuration example (CloudFormation YAML):
MyKey:Type:AWS::KMS::KeyProperties:Description:"CMK for SNS topic encryption"MyTopic:Type:AWS::SNS::TopicProperties:TopicName:my-topicKmsMasterKeyId:!Ref MyKey