Amazon Simple Notification Service
Developer Guide (API Version 2010-03-31)

Logging Amazon Simple Notification Service API Calls By Using AWS CloudTrail

Amazon SNS is integrated with CloudTrail, a service that captures API calls made by or on behalf of Amazon SNS in your AWS account and delivers the log files to an Amazon S3 bucket that you specify. CloudTrail captures API calls made from the Amazon SNS console or from the Amazon SNS API. Using the information collected by CloudTrail, you can determine what request was made to Amazon SNS, the source IP address from which the request was made, who made the request, when it was made, and so on. To learn more about CloudTrail, including how to configure and enable it, see the AWS CloudTrail User Guide.

Amazon SNS Information in CloudTrail

When CloudTrail logging is enabled in your AWS account, API calls made to Amazon SNS actions are tracked in log files. Amazon SNS records are written together with other AWS service records in a log file. CloudTrail determines when to create and write to a new file based on a time period and file size.

The following actions are supported:


When you are not logged in to Amazon Web Services (unauthenticated mode) and either the ConfirmSubscription or Unsubscribe actions are invoked, then they will not be logged to CloudTrail. Such as, when you click the provided link in an email notification to confirm a pending subscription to a topic, the ConfirmSubscription action is invoked in unauthenticated mode. In this example, the ConfirmSubscription action would not be logged to CloudTrail.

Every log entry contains information about who generated the request. The user identity information in the log helps you determine whether the request was made with root or IAM user credentials, with temporary security credentials for a role or federated user, or by another AWS service. For more information, see the userIdentity field in the CloudTrail Event Reference.

You can store your log files in your bucket for as long as you want, but you can also define Amazon S3 lifecycle rules to archive or delete log files automatically. By default, your log files are encrypted by using Amazon S3 server-side encryption (SSE).

You can choose to have CloudTrail publish Amazon SNS notifications when new log files are delivered if you want to take quick action upon log file delivery. For more information, see Configuring Amazon SNS Notifications.

You can also aggregate Amazon SNS log files from multiple AWS regions and multiple AWS accounts into a single Amazon S3 bucket. For more information, see Aggregating CloudTrail Log Files to a Single Amazon S3 Bucket.

Understanding Amazon SNS Log File Entries

CloudTrail log files contain one or more log entries where each entry is made up of multiple JSON-formatted events. A log entry represents a single request from any source and includes information about the requested action, any parameters, the date and time of the action, and so on. The log entries are not guaranteed to be in any particular order. That is, they are not an ordered stack trace of the public API calls.

The following example shows a CloudTrail log entry for the ListTopics, CreateTopic, and DeleteTopic actions.

{ "Records": [ { "eventVersion": "1.02", "userIdentity": { "type":"IAMUser", "userName":"Bob" "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::123456789012:user/Bob", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE" }, "eventTime": "2014-09-30T00:00:00Z", "eventSource": "", "eventName": "ListTopics", "awsRegion": "us-west-2", "sourceIPAddress": "", "userAgent": "aws-sdk-java/unknown-version", "requestParameters": { "nextToken": "ABCDEF1234567890EXAMPLE==" }, "responseElements": null, "requestID": "example1-b9bb-50fa-abdb-80f274981d60", "eventID": "example0-09a3-47d6-a810-c5f9fd2534fe", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }, { "eventVersion": "1.02", "userIdentity": { "type":"IAMUser", "userName":"Bob" "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::123456789012:user/Bob", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE" }, "eventTime": "2014-09-30T00:00:00Z", "eventSource": "", "eventName": "CreateTopic", "awsRegion": "us-west-2", "sourceIPAddress": "", "userAgent": "aws-sdk-java/unknown-version", "requestParameters": { "name": "hello" }, "responseElements": { "topicArn": "arn:aws:sns:us-west-2:123456789012:hello-topic" }, "requestID": "example7-5cd3-5323-8a00-f1889011fee9", "eventID": "examplec-4f2f-4625-8378-130ac89660b1", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }, { "eventVersion": "1.02", "userIdentity": { "type":"IAMUser", "userName":"Bob" "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::123456789012:user/Bob", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE" }, "eventTime": "2014-09-30T00:00:00Z", "eventSource": "", "eventName": "DeleteTopic", "awsRegion": "us-west-2", "sourceIPAddress": "", "userAgent": "aws-sdk-java/unknown-version", "requestParameters": { "topicArn": "arn:aws:sns:us-west-2:123456789012:hello-topic" }, "responseElements": null, "requestID": "example5-4faa-51d5-aab2-803a8294388d", "eventID": "example8-6443-4b4d-abfd-1b867280d964", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }, ] }