# hkb-forward-site-cutoff

Fires on: The site cutoff function disabling the site distribution.

Run the [common pre-checks](/wiki/runbooks/#common-pre-checks) first.

## Symptoms
An email from `hkb security alert` for a CloudFront `UpdateDistribution` call by the `hkb-site-cutoff` role in Prod. The month's CloudFront spend crossed its budget, and the cutoff function disabled the site distribution. The site stops answering until it is turned back on.

## Pre-checks
1. Read the month's CloudFront usage in Cost Explorer as HKB-ReadOnly (`ro-hkb-master`), by usage type, for the cause: a traffic spike, a crawler, or an attack.
2. Confirm the distribution is disabled: `aws cloudfront get-distribution --profile ro-hkb-prod --id <id>` shows `Enabled: false`.

## Resolution
- **A real spike that has passed:** turn the site back on with manual step H-12.6, `site-cutoff.sh restore`, which sets the distribution back to enabled, the state `hkb-site` already records. A `SiteOnline` pull request to false and then one back to true does the same through the pipeline. CloudFormation still records the distribution as enabled, so a plain pipeline run changes nothing.
- **Abuse still going on:** leave the site off and fix the cause first, for example a rate limit or a blocked source, in the templates.
- **A planned test:** manual step H-12.7, `site-cutoff.sh test`, publishes to the cutoff topic, and the same email follows. It tests the path from the topic onward; the budget's own publish isn't part of the test. Restore as above once the PASS line shows.

## Post-checks
The site answers again and the live check passes. The budget alerts once a month, so the cutoff can't fire again until the next month: watch the CloudFront spend by hand until then. After a planned test the budget hasn't alerted yet, so the cutoff stays armed.

## Rollback
A `SiteOnline` pull request to false takes the site off again.

## Alert details

| Property | Value |
| --- | --- |
| Runs in | Prod, us-east-1, forwarded to the `hkb-security-events` bus in Security |
| Email | From `hkb security alert`: `SECURITY EVENT <src> <what> in account <account>, <region>, at <time> by <who>.` |
| Source | `baseline/hkb-baseline-site-cutoff.yaml`, resource `CutoffForwardRule` |

The event pattern, as deployed:

```yaml
EventPattern:
  source: [aws.cloudfront]
  detail-type: [AWS API Call via CloudTrail]
  detail:
    eventSource: [cloudfront.amazonaws.com]
    eventName: [UpdateDistribution]
    userIdentity:
      sessionContext:
        sessionIssuer:
          userName: [hkb-site-cutoff]
```
