Description
CloudFront request logs show which paths viewers requested and which status codes the distribution returned.
Potential impact
Missing request records make traffic spikes and errors harder to explain.
Remediation
For legacy standard logging, set DistributionConfig.Logging.Bucket to the domain name of an ACL-enabled S3 bucket and permit CloudFront log delivery. Set retention, send test traffic and check for request records. Configure standard logging v2 separately if you use it.
Examples
The example writes under cloudfront/ in the log bucket and excludes cookies. Supply the distribution’s default cache behavior separately.
Before
yaml
Resources:
WebDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Enabled: true
Origins:
- DomainName: mybucket.s3.amazonaws.com
Id: myS3Origin
S3OriginConfig:
OriginAccessIdentity: origin-access-identity/cloudfront/E127EXAMPLE51Z
After
yaml
Resources:
WebDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Enabled: true
Origins:
- DomainName: mybucket.s3.amazonaws.com
Id: myS3Origin
S3OriginConfig:
OriginAccessIdentity: origin-access-identity/cloudfront/E127EXAMPLE51Z
Logging:
Bucket: mylogs.s3.amazonaws.com
Prefix: cloudfront/
IncludeCookies: false