Menu
Amazon CloudFront
Developer Guide (API Version 2016-09-29)

Using AWS CloudTrail to Capture Requests Sent to the CloudFront API

CloudFront is integrated with CloudTrail, an AWS service that captures information about every request that is sent to the CloudFront API by your AWS account, including your IAM users. CloudTrail periodically saves log files of these requests to an Amazon S3 bucket that you specify. CloudTrail captures information about all requests, whether they were made using the CloudFront console, the CloudFront API, the AWS SDKs, the CloudFront CLI, or another service, for example, AWS CloudFormation.

You can use information in the CloudTrail log files to determine which requests were made to CloudFront, the source IP address from which each 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.

Note

CloudFront is a global service. To view CloudFront requests in CloudTrail logs, you must update an existing trail to include global services. For more information, see Updating a Trail and About Global Service Events in the AWS CloudTrail User Guide.

CloudFront Information in CloudTrail Log Files

When you enable CloudTrail, CloudTrail captures every request that you make to every AWS service that CloudTrail supports. (For a list of supported services, see Supported Services in the AWS CloudTrail User Guide.) The log files aren't organized or sorted by service; each log file might contain records from more than one service. CloudTrail determines when to create a new log file.

Note

CloudTrail supports all CloudFront API actions.

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

You can store log files for as long as you want. 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 in the AWS CloudTrail User Guide.

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

Understanding CloudFront Log File Entries

Each JSON-formatted CloudTrail log file can contain one or more log entries. A log entry represents a single request from any source and includes information about the requested action, including any parameters, the date and time of the action, and so on. The log entries are not guaranteed to be in any particular order; they are not an ordered stack trace of API calls.

The eventName element identifies the action that occurred and the API version that was used to perform that action. For example, the following eventName value indicates that a web distribution was updated, and the 2014-01-31 API version was used to perform the action:

UpdateDistribution2014_01_31

The following example shows a CloudTrail log entry that demonstrates five actions:

  • Updating a web distribution configuration. The value of eventName is UpdateDistribution.

  • Listing web distributions that are associated with the current account. The value of eventName is ListDistributions.

  • Getting the configuration for a specific web distribution. The value of eventName is GetDistribution.

  • Creating an invalidation batch request. The value of eventName is CreateInvalidation.

  • Listing origin access identities that are associated with the current account. The value of eventName is ListCloudFrontOriginAccessIdentities.

{
   "Records": [{
      "eventVersion": "1.01",
      "userIdentity": {
         "type": "IAMUser",
         "principalId": "A1B2C3D4E5F6G7EXAMPLE",
         "arn": "arn:aws:iam::111122223333:user/smithj",
         "accountId": "111122223333",
         "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
         "userName": "smithj"
      },
      "eventTime": "2014-05-06T18:00:32Z",
      "eventName": "UpdateDistribution2014_01_31",
      "sourceIPAddress": "192.0.2.17",
      "userAgent": "aws-sdk-ruby/1.39.0 ruby/1.9.3 x86_64-linux",
      "requestParameters": {
         "id": "EDFDVBD6EXAMPLE",
         "ifMatch": "E9LHASXEXAMPLE",
         "distributionConfig": {
            "restrictions": {
               "geoRestriction": {
                  "quantity": 0,
                  "restrictionType": "none"
               }
            },
            "customErrorResponses": {
               "quantity": 0
            },
            "defaultRootObject": "index.html",
            "aliases": {
               "quantity": 1,
               "items": ["example.com"]
            },
            "logging": {
               "bucket": "",
               "enabled": false,
               "prefix": "",
               "includeCookies": false
            },
            "viewerCertificate": {
               "iAMCertificateId": "A1B2C3D4E5F6G7EXAMPLE",
               "sSLSupportMethod": "sni-only"
            },
            "callerReference": "2014-05-06 64832",
            "defaultCacheBehavior": {
               "targetOriginId": "Images",
               "allowedMethods": {
                  "items": ["GET",
                  "HEAD"],
                  "quantity": 2
               },
               "forwardedValues": {
                  "cookies": {
                     "forward": "none"
                  },
                  "queryString": false
               },
               "minTTL": 300,
               "trustedSigners": {
                  "enabled": false,
                  "quantity": 0
               },
               "viewerProtocolPolicy": "redirect-to-https",
               "smoothStreaming": false
            },
            "origins": {
               "items": [{
                  "customOriginConfig": {
                     "hTTPSPort": 443,
                     "originProtocolPolicy": "http-only",
                     "hTTPPort": 80
                  },
                  "domainName": "myawsbucket.s3-website-us-east-1.amazonaws.com",
                  "id": "Web page origin"
               },
               {
                  "customOriginConfig": {
                     "hTTPSPort": 443,
                     "originProtocolPolicy": "http-only",
                     "hTTPPort": 80
                  },
                  "domainName": "myotherawsbucket.s3-website-us-west-2.amazonaws.com",
                  "id": "Images"
               }],
               "quantity": 2
            },
            "enabled": true,
            "cacheBehaviors": {
                  "allowedMethods": {
                     "items": ["GET",
                     "HEAD"],
                     "quantity": 2
                  },
                  "trustedSigners": {
                     "enabled": false,
                     "quantity": 0
                  },
                  "targetOriginId": "Web page origin",
                  "smoothStreaming": false,
                  "viewerProtocolPolicy": "redirect-to-https",
                  "minTTL": 300,
                  "forwardedValues": {
                     "cookies": {
                        "forward": "none"
                     },
                     "queryString": false
                  },
                  "pathPattern": "*.html"
               }],
               "quantity": 1
            },
            "priceClass": "PriceClass_All",
            "comment": "Added an origin and a cache behavior"
         }
      },
      "responseElements": {
         "eTag": "E2QWRUHEXAMPLE",
         "distribution": {
            "domainName": "d111111abcdef8.cloudfront.net",
            "status": "InProgress",
            "distributionConfig": {
            distributionConfig response omitted
            },
            "id": "EDFDVBD6EXAMPLE",
            "lastModifiedTime": "May 6, 2014 6:00:32 PM",
            "activeTrustedSigners": {
               "quantity": 0,
               "enabled": false
            },
            "inProgressInvalidationBatches": 0
         }
      },
      "requestID": "4e6b66f9-d548-11e3-a8a9-73e33example",
      "eventID": "5ab02562-0fc5-43d0-b7b6-90293example"
   },
   {
      "eventVersion": "1.01",
      "userIdentity": {
         "type": "IAMUser",
         "principalId": "A1B2C3D4E5F6G7EXAMPLE",
         "arn": "arn:aws:iam::111122223333:user/smithj",
         "accountId": "111122223333",
         "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
         "userName": "smithj"
      },
      "eventTime": "2014-05-06T18:01:35Z",
      "eventName": "ListDistributions2014_01_31",
      "sourceIPAddress": "192.0.2.17",
      "userAgent": "aws-sdk-ruby/1.39.0 ruby/1.9.3 x86_64-linux",
      "requestParameters": null,
      "responseElements": null,
      "requestID": "52de9f97-d548-11e3-8fb9-4dad0example",
      "eventID": "eb91f423-6dd3-4bb0-a148-3cdfbexample"
   },
   {
      "eventVersion": "1.01",
      "userIdentity": {
         "type": "IAMUser",
         "principalId": "A1B2C3D4E5F6G7EXAMPLE",
         "arn": "arn:aws:iam::111122223333:user/smithj",
         "accountId": "111122223333",
         "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
         "userName": "smithj"
      },
      "eventTime": "2014-05-06T18:01:59Z",
      "eventName": "GetDistribution2014_01_31",
      "sourceIPAddress": "192.0.2.17",
      "userAgent": "aws-sdk-ruby/1.39.0 ruby/1.9.3 x86_64-linux",
      "requestParameters": {
         "id": "EDFDVBD6EXAMPLE"
      },
      "responseElements": null,
      "requestID": "497b3622-d548-11e3-8fb9-4dad0example",
      "eventID": "c32289c7-005a-46f7-9801-cba41example"
   },
   {
      "eventVersion": "1.01",
      "userIdentity": {
         "type": "IAMUser",
         "principalId": "A1B2C3D4E5F6G7EXAMPLE",
         "arn": "arn:aws:iam::111122223333:user/smithj",
         "accountId": "111122223333",
         "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
         "userName": "smithj"
      },
      "eventTime": "2014-05-06T18:02:27Z",
      "eventName": "CreateInvalidation2014_01_31",
      "sourceIPAddress": "192.0.2.17",
      "userAgent": "aws-sdk-ruby/1.39.0 ruby/1.9.3 x86_64-linux",
      "requestParameters": {
         "invalidationBatch": {
            "callerReference": "2014-05-06 64947",
            "paths": {
               "quantity": 3,
               "items": ["/images/new.jpg",
               "/images/logo.jpg",
               "/images/banner.jpg"]
            }
         },
         "distributionId": "EDFDVBD6EXAMPLE"
      },
      "responseElements": {
         "invalidation": {
            "createTime": "May 6, 2014 6:02:27 PM",
            "invalidationBatch": {
               "callerReference": "2014-05-06 64947",
               "paths": {
                  "quantity": 3,
                  "items": ["/images/banner.jpg",
                  "/images/logo.jpg",
                  "/images/new.jpg"]
               }
            },
            "status": "InProgress",
            "id": "ISRZ85EXAMPLE"
         },
         "location": "https://cloudfront.amazonaws.com/2014-01-31/distribution/EDFDVBD6EXAMPLE/invalidation/ISRZ85EXAMPLE"
      },
      "requestID": "4e200613-d548-11e3-a8a9-73e33example",
      "eventID": "191ebb93-66b7-4517-a741-92b0eexample"
   },
   {
      "eventVersion": "1.01",
      "userIdentity": {
         "type": "IAMUser",
         "principalId": "A1B2C3D4E5F6G7EXAMPLE",
         "arn": "arn:aws:iam::111122223333:user/smithj",
         "accountId": "111122223333",
         "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
         "userName": "smithj"
      },
      "eventTime": "2014-05-06T18:03:08Z",
      "eventName": "ListCloudFrontOriginAccessIdentities2014_01_31",
      "sourceIPAddress": "192.0.2.17",
      "userAgent": "aws-sdk-ruby/1.39.0 ruby/1.9.3 x86_64-linux",
      "requestParameters": null,
      "responseElements": null,
      "requestID": "42ca4299-d548-11e3-8fb9-4dad0example",
      "eventID": "7aeb434f-eb55-4e2a-82d8-417d5example"
   }]
}