Description
CloudFront access logs show the viewer’s request path, response status and processing time.
Potential impact
Without a request history, it is harder to trace errors or identify unusual traffic at the edge.
Remediation
For legacy standard logging, set logging.enabled: true and choose an S3 bucket and prefix. Enable bucket ACLs, grant CloudFront log delivery access and restrict who can read the logs. Set a retention period. If you use standard logging v2 or real-time logging, check that configuration separately.
Examples
Both tasks omit required cache behavior and set the distribution’s enabled to false. Verify delivery on a distribution that is serving traffic.
Before
- name: create a CloudFront distribution
community.aws.cloudfront_distribution:
state: present
caller_reference: unique test distribution ID
origins:
- id: my test origin-000111
domain_name: www.example.com
enabled: false
After
- name: create a CloudFront distribution
community.aws.cloudfront_distribution:
state: present
caller_reference: unique test distribution ID
origins:
- id: my test origin-000111
domain_name: www.example.com
logging:
enabled: true
include_cookies: false
bucket: mylogbucket.s3.amazonaws.com
prefix: myprefix/
enabled: false
The second task omits cookies from the logs. After test traffic, look for request records under myprefix/. Standard logs can arrive late or omit requests.