Traffic job
A CodeBuild job in Prod that counts the site's visitors once a day, from CloudFront's request metrics and the access logs in Log Archive, and publishes totals only.
Flow
Addresses stay in Log Archive and in the job's memory. Only totals reach the site.
Configuration
| Setting | Value |
|---|---|
| Schedule | EventBridge Scheduler, daily at 01:30 UTC, after the day before is complete; 2 retries. The scheduler's role, hkb-site-traffic-schedule, may only start this project |
| Job | CodeBuild project hkb-site-traffic, no source, 10-minute timeout. CodeBuild rather than Lambda: the script is longer than CloudFormation's 4 KB inline code limit |
| Reads | The site access logs in Log Archive (the last 30 days, across accounts) and CloudFront's Requests metric |
| Counts | A visitor is a browser that loaded a page's files that day as well as its HTML. Visitors are counted from hashes held in memory; the logs are copied to the build's disk and go with the container |
| Writes | One script file of totals in the site bucket. No address is ever published, and the owner's own addresses are left out of the counts |
| Settings | The data file's key and the owner's addresses are SSM parameters set by a manual step (H-7.16), so neither is in the repository |
| Role | hkb-site-traffic: read the log bucket and its key in Log Archive, read the metric, write the one file. Its logs go to /aws/codebuild/hkb-site-traffic, kept 90 days |
| Deployed by | The hkb-baseline-site-traffic StackSet, to Prod only |
Sources
Page information
- Owner
- Platform Engineering
- Status
- current Current: generated from the templates and records in the repository at this build.
- Generated from
baseline/hkb-baseline-site-traffic.yaml- Linked from
- Prod, Site distribution