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-cloudtrail-sns-topic-name-undefined.md.
A documentation index is available at /llms.txt.
CloudTrail trails should be configured to publish notifications to an Amazon SNS topic so that security teams receive real-time alerts for suspicious events and automated workflows can be triggered for faster detection and response.
This rule checks AWS::CloudTrail::Trail resources to ensure the SnsTopicName property is defined and non-empty. Resources missing SnsTopicName or with SnsTopicName set to "" will be flagged. Ensure the property references a valid Amazon SNS topic that allows CloudTrail to publish.
AWSTemplateFormatVersion:"2010-09-09"Parameters:OperatorEmail:Description:"Email address to notify when new logs are published."Type:StringResources:myTrail:DependsOn:- BucketPolicy- TopicPolicyType:AWS::CloudTrail::TrailProperties:EnableLogFileValidation:trueS3BucketName:Ref:S3BucketSnsTopicName:Fn::GetAtt:- Topic- TopicNameIsLogging:trueIsMultiRegionTrail:true
{"AWSTemplateFormatVersion":"2010-09-09","Parameters":{"OperatorEmail":{"Type":"String","Description":"Email address to notify when new logs are published."}},"Resources":{"myTrail2":{"DependsOn":["BucketPolicy","TopicPolicy"],"Type":"AWS::CloudTrail::Trail","Properties":{"IsLogging":true,"IsMultiRegionTrail":true,"EnableLogFileValidation":true,"S3BucketName":{"Ref":"S3Bucket"},"SnsTopicName":{"Fn::GetAtt":["Topic","TopicName"]}}},"S3Bucket":{"DeletionPolicy":"Retain","Type":"AWS::S3::Bucket","Properties":{}}}}
Non-Compliant Code Examples
AWSTemplateFormatVersion:"2010-09-09"Parameters:OperatorEmail:Description:"Email address to notify when new logs are published."Type:StringResources:myTrail3:DependsOn:- BucketPolicy- TopicPolicyType:AWS::CloudTrail::TrailProperties:S3BucketName:Ref:S3BucketIsLogging:falseIsMultiRegionTrail:truemyTrail4:DependsOn:- BucketPolicy- TopicPolicyType:AWS::CloudTrail::TrailProperties:EnableLogFileValidation:falseS3BucketName:Ref:S3BucketSnsTopicName:""IsLogging:falseIsMultiRegionTrail:true
{"Resources":{"myTrail5":{"DependsOn":["BucketPolicy","TopicPolicy"],"Type":"AWS::CloudTrail::Trail","Properties":{"IsMultiRegionTrail":true,"S3BucketName":{"Ref":"S3Bucket"},"IsLogging":false}},"myTrail6":{"DependsOn":["BucketPolicy","TopicPolicy"],"Type":"AWS::CloudTrail::Trail","Properties":{"EnableLogFileValidation":false,"S3BucketName":{"Ref":"S3Bucket"},"SnsTopicName":"","IsLogging":false,"IsMultiRegionTrail":true}}},"AWSTemplateFormatVersion":"2010-09-09","Parameters":{"OperatorEmail":{"Description":"Email address to notify when new logs are published.","Type":"String"}}}
1
2
rulesets:- CloudFormation / AWS # Rules to enforce / AWS.
Request a personalized demo
Get Started with Datadog
Ask AI
AI-generated responses may be inaccurate. Verify important info.