Cost cutoff
If CloudFront charges in Prod pass $5 in a month, a Lambda function disables the site's distribution: a traffic flood takes the site dark instead of running up the bill.
Flow
The numbers trace one cutoff, from the budget alert to the email that says the site went dark.
Configuration
| Setting | Value |
|---|---|
| Budget | hkb-site-cloudfront: monthly cost budget of $5 on Amazon CloudFront, alerting on actual spend over 100% |
| Topic | An SNS topic encrypted under its own KMS key, which only AWS Budgets may publish to |
| Function | hkb-site-cutoff, python3.13 on arm64, 128 MB, 60 s. It reads the distribution ID from the site stack's outputs and sets Enabled to false; if it is already off, it does nothing |
| Role | hkb-site-cutoff: read the site stack, and get and update only a distribution tagged Component: site |
| Alert | The function's UpdateDistribution call is forwarded to the central bus in Security and emailed as a security event |
| Turning it back on | A manual step (H-12.6) after reading the month's usage, or a SiteOnline change through the pipeline. The budget alerts once a month, so it can't fire again until the next |
| Why a function | AWS Budgets actions can apply IAM or SCP policies and stop EC2 or RDS, but they can't disable a CloudFront distribution |
| Deployed by | The hkb-baseline-site-cutoff 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-cutoff.yaml- Linked from
- Prod, Site distribution