|
| 1 | +# CloudFront Holding Page Runbook |
| 2 | + |
| 3 | +This folder contains helper scripts used to switch Find a Grant between live origins and a static S3 holding page, and to update the holding page content. |
| 4 | + |
| 5 | +## Script locations |
| 6 | + |
| 7 | +- Runtime scripts are in `gap-find-web/aws/s3/` |
| 8 | + |
| 9 | +## First stage: download scripts in CloudShell |
| 10 | + |
| 11 | +Start by copying the latest scripts from S3 into your current CloudShell directory: |
| 12 | + |
| 13 | +```bash |
| 14 | +aws s3 cp "s3://gap-setup-holding-page" . --recursive |
| 15 | +``` |
| 16 | + |
| 17 | +## Environments and IDs |
| 18 | + |
| 19 | +| Environment | CloudFront distribution ID | Holding page S3 bucket | Holding page origin | |
| 20 | +|---|---|---|---| |
| 21 | +| `qa` | `E2YMATUXLSFFJV` | `gap-qa-holding-page` | `gap-qa-holding-page.s3-website.eu-west-2.amazonaws.com` | |
| 22 | +| `prod` | `E3GJQ1JB1DFNU4` | `gap-prod-holding-page` | `gap-prod-holding-page.s3-website.eu-west-2.amazonaws.com` | |
| 23 | + |
| 24 | +## What the switch scripts change |
| 25 | + |
| 26 | +`switch-to-holding-page.sh` updates these cache behaviors to point to the holding page origin: |
| 27 | + |
| 28 | +- `/` |
| 29 | +- `/*` |
| 30 | +- `/grants/*` |
| 31 | +- `/apply/applicant` |
| 32 | +- `/apply/applicant/*` |
| 33 | +- `/apply/admin` |
| 34 | +- `/apply/admin/*` |
| 35 | + |
| 36 | +It also: |
| 37 | + |
| 38 | +- Forces those switched behaviors to use GET-only methods (`HEAD`, `GET`, `OPTIONS`) |
| 39 | +- Adds/overwrites a CloudFront custom error for `404 -> /index.html` with response code `200` |
| 40 | +- Creates a full cache invalidation for `/*` |
| 41 | + |
| 42 | +`switch-to-live.sh` reverses this: |
| 43 | + |
| 44 | +- Restores the switched behaviors to live origins (`find-lb` or `apply-lb` depending on path) |
| 45 | +- Restores allowed methods per behavior (`7 methods` for apply paths, `3 methods` for find paths) |
| 46 | +- Removes the `404 -> /index.html` custom error response |
| 47 | +- Creates a full cache invalidation for `/*` |
| 48 | + |
| 49 | +Both switch scripts prompt for `qa` or `prod`, include explicit confirmation prompts, and create a timestamped backup file (`dist-backup-YYYYMMDD-HHMMSS.json`) before making changes. |
| 50 | + |
| 51 | +## Scripts |
| 52 | + |
| 53 | +### `s3/switch-to-holding-page.sh` |
| 54 | + |
| 55 | +Switches selected paths to the S3 holding page for the chosen environment (`qa` or `prod`), then invalidates CloudFront. |
| 56 | + |
| 57 | +```bash |
| 58 | +sh ./switch-to-holding-page.sh |
| 59 | +``` |
| 60 | + |
| 61 | +### `s3/switch-to-live.sh` |
| 62 | + |
| 63 | +Restores selected paths to live load balancer origins for the chosen environment (`qa` or `prod`), then invalidates CloudFront. |
| 64 | + |
| 65 | +```bash |
| 66 | +sh ./switch-to-live.sh |
| 67 | +``` |
| 68 | + |
| 69 | +### `s3/restore-from-backup.sh` - Be careful with this! |
| 70 | + |
| 71 | +Restores from a backup file and invalidates CloudFront. |
| 72 | +Prompts for environment (`qa` or `prod`) before restoring. |
| 73 | + |
| 74 | +```bash |
| 75 | +sh ./restore-from-backup.sh dist-backup-20260414-162948.json |
| 76 | +``` |
| 77 | + |
| 78 | +If run without an argument, it prints usage and available backup files. |
| 79 | + |
| 80 | +### `s3/update-holding-page.sh` |
| 81 | + |
| 82 | +Updates `holding-page/index.html`, uploads the generated page to the selected environment bucket (`qa` or `prod`), and invalidates `/index.html`. |
| 83 | + |
| 84 | +What it prompts for: |
| 85 | + |
| 86 | +- Environment (`qa`/`prod`) |
| 87 | +- Optional custom page message (defaults to `Please try again later.`) |
| 88 | +- Confirmation (plus an extra production warning prompt for `prod`) |
| 89 | + |
| 90 | +```bash |
| 91 | +sh ./update-holding-page.sh |
| 92 | +``` |
| 93 | + |
| 94 | +### `s3/clear-cache-invalidate.sh` |
| 95 | + |
| 96 | +Prompts for environment (`qa` or `prod`) and creates a full invalidation (`/*`) for that distribution. |
| 97 | + |
| 98 | +```bash |
| 99 | +sh ./clear-cache-invalidate.sh |
| 100 | +``` |
| 101 | + |
| 102 | +## Suggested maintenance procedure |
| 103 | + |
| 104 | +1. Update the holding page content first (optional): |
| 105 | + ```bash |
| 106 | + sh ./update-holding-page.sh |
| 107 | + ``` |
| 108 | +2. Switch traffic to the holding page: |
| 109 | + ```bash |
| 110 | + sh ./switch-to-holding-page.sh |
| 111 | + ``` |
| 112 | +3. Verify key URLs show the holding page. |
| 113 | +4. Perform maintenance. |
| 114 | +5. Switch traffic back to live: |
| 115 | + ```bash |
| 116 | + sh ./switch-to-live.sh |
| 117 | + ``` |
| 118 | +6. Verify live traffic is restored. |
| 119 | + |
| 120 | +## Recovery procedure |
| 121 | + |
| 122 | +If needed, restore from a known backup file - Be very careful though! |
| 123 | + |
| 124 | +```bash |
| 125 | +sh ./restore-from-backup.sh dist-backup-YYYYMMDD-HHMMSS.json |
| 126 | +``` |
| 127 | + |
| 128 | +Note: `restore-from-backup.sh` fetches the current ETag before update, so backup-file ETag staleness is not a problem. |
0 commit comments