CloudFront Invalidation Operator
What this skill does
Executes CloudFront cache invalidation operations correctly and
cost-effectively. Runs deterministic pre-checks before any
state-changing CLI (distribution is Deployed, caller has
cloudfront:CreateInvalidation permission, path patterns are
syntactically valid, path count is under the free-tier threshold or
cost is acknowledged), executes the create-invalidation CLI behind
a CONFIRM gate, and verifies the result by polling
get-invalidation until InvalidationStatus: Completed. Every
invalidation produces a cost note (1-1000 paths free per month, then
$0.005/path) and a cache-busting strategy comparison (invalidation vs
versioned filenames). Continuous deployment distributions route to
the staging distribution for invalidation before promotion.
Quick navigation
| Section |
What it covers |
When to read it |
| § Quick reference |
Verdict thresholds (BLOCKED/READY/COMPLETED) + pre-check priority |
Before any operation |
| § Mindset |
Why invalidation is a blunt tool, the free-tier trap, the cache-busting hierarchy |
Understanding the cost model |
| § Pre-flight |
Distribution metadata gate — Deployed state, caller IAM, path syntax |
Before executing any CLI |
| § Process |
Per-operation planning: create, wait, cost-analysis, compare-strategy, diagnose |
When choosing which operation to run |
| § Output format |
STRICT output contract — OPERATION/VERDICT/PRE_CHECKS/STEPS/POST_VERIFY template |
Formatting the response |
| § Anti-Patterns |
NEVER list — top mistakes that waste money or leave stale cache |
Review before risky operations |
| § Pre-flight safety |
Capture pre-state, distribution config verification, cost capture |
Defense-in-depth |
Quick reference — verdict thresholds
| Verdict |
Trigger condition |
Action |
BLOCKED |
One or more pre-checks failed (distribution not Deployed, caller lacks cloudfront:CreateInvalidation, path pattern syntax invalid, continuous deployment primary without staging awareness) |
List failures, do NOT execute |
READY |
All pre-checks passed; awaiting CONFIRM gate |
Emit exact CLI sequence, wait for operator yes |
COMPLETED |
Invalidation created and InvalidationStatus: Completed confirmed via get-invalidation |
Emit verification results, cost summary, monitoring plan |
Priority order for pre-checks (apply in this sequence, all must pass
for READY):
- Distribution reachability — distribution exists
(
get-distribution does not return NoSuchResource), and the
distribution ID is valid.
- Distribution is Deployed —
Status: Deployed (not
InProgress, Deleting, or Suspended). Invalidation on a
non-Deployed distribution may fail or have no effect.
- Path pattern syntax — each path starts with
/, uses
ASCII-safe characters, and wildcard * appears only at the end
of a path segment (e.g. /images/*.jpg is valid;
/images/*/header.jpg is NOT valid).
- Path count vs free tier — the first 1,000 invalidation paths
per month are free; paths beyond 1,000 cost $0.005 each. If the
path count exceeds 1,000, surface a cost warning in the plan.
- Caller IAM permission — the calling identity must have
cloudfront:CreateInvalidation on the distribution ARN. Without
it, create-invalidation returns AccessDenied.
- Continuous deployment awareness — if the distribution has a
ContinuousDeploymentPolicyId, invalidations should target the
STAGING distribution for testing before promotion to the primary.
- CallerRef uniqueness —
CallerReference must be unique per
invalidation. Reusing a CallerReference silently deduplicates
(returns the existing invalidation without creating a new one).
Cost/time baselines (2026):
- First 1,000 invalidation paths per month: free (across all
distributions in the account).
- Paths 1,001+: $0.005 per path per month.
- A single
/* invalidation counts as ONE path (covers all objects).
- A
/images/* invalidation also counts as ONE path.
- Listing each object individually (
/index.html, /style.css,
/logo.png) counts as one path EACH — 3 paths for 3 objects.
- Invalidation propagation: typically 10-120 seconds for global
edge locations. CloudFront does not publish a strict SLA for
invalidation completion.
InvalidationStatus: InProgress → Completed transition: usually
under 60 seconds for small path counts, up to 10+ minutes for
large wildcard invalidations.
Mindset
One-line takeaway: CloudFront invalidation is a blunt instrument
— /* clears everything in one free path, but listing individual
objects burns through the 1,000-path free tier and costs $0.005 per
extra path. Driven by three CloudFront realities:
Versioned filenames beat invalidation for routine deploys. If
your CI/CD pipeline renames assets on every build (app.abc123.js
instead of app.js), the new file is fetched on first request with
no invalidation needed. Invalidation is for emergency content
removal, hotfixes to unversioned assets, or removing sensitive data
already cached at the edge. Always prefer versioned filenames for
routine releases.
/* is the most cost-effective invalidation. A single /*
invalidation counts as ONE path (free tier) and invalidates every
object in the distribution. Listing 500 individual paths consumes
500 of your 1,000 free paths. If you need to invalidate more than
~60% of your site, /* is cheaper than per-path invalidation.
Continuous deployment changes the invalidation target. With a
CloudFront continuous deployment policy, traffic is split between
the primary and staging distributions. Invalidation on the primary
does NOT invalidate the staging distribution's edge cache. You must
invalidate both (or invalidate staging first, then promote).
Pre-flight: distribution metadata gate
Run before classification. Misclassifying these produces wrong plans.
Pagination: list-distributions paginates at 200/page — drain
--marker/--next-marker to completion. list-invalidations
paginates at 100/page.
Live-account pre-flight (get-distribution capture, list-invalidations history, continuous-deployment policy, monthly path-count tally) moved verbatim to references/diagnostic-commands.md.
Load them before classifying an operation on a live account.
Malformed input: if the input is invalid or missing required
fields, emit VERDICT: ERROR with REASON: Distribution configuration is not valid or is missing required fields — cannot plan. and REMEDIATION: Re-fetch with aws cloudfront get-distribution --id <id> --output json and re-plan.
| Distribution attribute |
Effect on operation |
Status: InProgress |
BLOCKED — distribution update in flight. Wait for Deployed. |
Status: Deployed |
OK — distribution is live, invalidation can proceed. |
Status: Suspended |
BLOCKED — distribution is suspended. Restore via update-distribution with Enabled: true. |
Status: Deleting |
BLOCKED — distribution being deleted. No invalidation possible. |
Enabled: false |
BLOCKED — distribution disabled. Invalidation may fail or have no effect. |
ContinuousDeploymentPolicyId present |
INFO — continuous deployment active. Invalidation should target staging first, then primary on promotion. |
| Path count > 1,000 (monthly cumulative) |
ADVISORY — paths beyond 1,000 cost $0.005 each. Surface cost in the plan. |
Path contains * mid-segment |
BLOCKED — wildcard only valid at end of a path segment. |
CallerReference collides with existing |
BLOCKED — CallerReference must be unique. Generate a new one. |
Process — operation planning (apply in order)
Step 0: Expert heuristic — non-obvious CloudFront behaviors
Step 0 expert heuristics (/* path counting, versioned filenames, CallerReference dedup, wildcard scope, browser cache, continuous-deployment targets, origin rollback, per-edge status, 3,000-path limit, function propagation, origin-type invariance) moved verbatim to references/advanced-patterns.md.
Load on demand before producing the operation plan.
Step 1: Pre-check gate — BLOCKED if any check fails
Run ALL pre-checks for the chosen operation. If ANY fails, the verdict
is BLOCKED with the failed checks in PRE_CHECKS. Do NOT execute.
For ALL operations:
- Distribution exists (
get-distribution does not return
NoSuchResource).
- Distribution
Status: Deployed.
DistributionConfig.Enabled: true.
For create-invalidation:
4. Path patterns are syntactically valid (start with /, wildcard
only at segment end, no more than 3,000 paths per batch).
5. Calling identity has cloudfront:CreateInvalidation on the
distribution ARN.
6. CallerReference is unique (not in recent list-invalidations).
7. (Advisory) Path count + monthly cumulative > 1,000: surface cost
warning.
For wait-invalidation (read-only):
4. get-invalidation --id <id> returns a valid invalidation with
InvalidationStatus.
5. (Advisory) If InvalidationStatus: InProgress for > 15 minutes,
surface a warning (typically completes in under 5 minutes).
For cost-analysis (read-only):
4. list-invalidations for all distributions this month — sum
Paths.Quantity across all invalidations.
5. Compare cumulative path count vs the 1,000-path free tier.
For compare-strategy (read-only):
4. Analyze the deployment workflow: are assets versioned? Is the
origin S3 or custom? What is the typical change frequency?
5. Recommend invalidation vs versioned filenames based on workflow.
For diagnose-invalidation (read-only):
4. Read get-invalidation, list-invalidations, distribution config,
and the failure-mode table to identify why an invalidation is
stuck, not working, or unexpectedly expensive.
Invalidation failure-mode table (AccessDenied, InvalidArgument, TooManyInvalidationsInProgress, CallerReference collisions, staging failures, cost surprises) moved verbatim to references/error-handling.md.
Load it during diagnose-invalidation operations.
Step 2: READY — emit operation plan
If all pre-checks pass, emit VERDICT: READY with the exact CLI
sequence and the CONFIRM gate. The plan includes:
- The exact AWS CLI command with all flags populated from the
distribution configuration.
- The expected path count and cost (free tier or $0.005/path beyond
1,000).
- The
CallerReference value (unique per invalidation).
- The expected side-effects (edge cache cleared for matching paths,
next request fetches fresh content from origin).
- The CONFIRM gate prompt.
- The verification step (
get-invalidation polling until Completed).
Step 3: Execute behind CONFIRM gate
- MANDATORY CONFIRMATION GATE. Before any state-changing CLI
(
create-invalidation), emit:
CONFIRM: About to create a CloudFront invalidation on distribution <id> (domain <domain>). Paths: <path-list-or-pattern>. Estimated cost: <$X or "free tier">. This will clear edge cache for matching paths. Proceed? (yes/no). Do NOT execute until the operator
confirms.
- Capture pre-state for audit:
aws cloudfront list-invalidations --distribution-id <id> --max-items 5 --output json > /tmp/<id>-invalidations-pre-$(date +%s).json.
- Execute the CLI.
create-invalidation returns immediately with an
Invalidation object containing the Id and
InvalidationStatus: InProgress.
- For continuous deployment: execute on the STAGING distribution
first (if testing), then the PRIMARY distribution after promotion.
Step 4: Post-verification — COMPLETED
After the CLI completes, run post-verification. ALL checks must pass
for COMPLETED.
get-invalidation --distribution-id <id> --id <invalidation-id>
— confirm InvalidationStatus: Completed.
list-invalidations --distribution-id <id> — confirm the new
invalidation appears in the list with Completed status.
- Spot-check:
curl -I https://<domain>/<path> — confirm
X-Cache: RefreshHit from CloudFront (re-fetched from origin) or
X-Cache: Miss from CloudFront (first fetch after invalidation).
- (Continuous deployment) Confirm the staging distribution
invalidation (if applicable) is also Completed.
- Cost verification: confirm the path count billed matches the plan
(first 1,000 free, $0.005/path beyond).
If ANY verification fails, emit VERDICT: ERROR with the failure
details — do not claim COMPLETED.
Output format (STRICT output contract — per operation)
OPERATION: <create-invalidation | wait-invalidation | cost-analysis | compare-strategy | diagnose-invalidation>
VERDICT: READY | BLOCKED | COMPLETED
TARGET: <distribution-id> (domain: <domain-name>, account <account>)
PRE_CHECKS:
- [PASS] <check description>
- [FAIL] <check description> — <reason>
STEPS:
1. <CLI command with flags populated>
2. <wait / monitoring command>
3. <next step>
POST_VERIFY:
- [PASS] <verification description>
- [FAIL] <verification description> — <reason>
COST: <free tier | $X.XX for N paths beyond free tier>
NOTES: <cache-busting recommendation, monitoring, caveats>
Worked example — create-invalidation /* (all paths)
OPERATION: create-invalidation
VERDICT: READY
TARGET: E1ABC2DEF3GHI4 (domain: d111111abcdef8.cloudfront.net,
account 111111111111)
PRE_CHECKS:
- [PASS] Distribution exists
- [PASS] Status: Deployed
- [PASS] Enabled: true
- [PASS] Path pattern: /* (valid — single wildcard path)
- [PASS] Calling role has cloudfront:CreateInvalidation on
arn:aws:cloudfront::111111111111:distribution/E1ABC2DEF3GHI4
- [PASS] CallerReference: inv-20260810-001 (unique)
- [INFO] Path count: 1 (free tier — 1 of 1,000 monthly paths used)
STEPS:
1. CONFIRM: About to create a CloudFront invalidation on
distribution E1ABC2DEF3GHI4 (d111111abcdef8.cloudfront.net).
Paths: /* (all objects). Cost: free tier. This will clear edge
cache for ALL objects globally. Next requests will fetch from
origin. Proceed? (yes/no)
2. aws cloudfront create-invalidation \
--distribution-id E1ABC2DEF3GHI4 \
--invalidation-batch '{"CallerReference":"inv-20260810-001",
"Paths":{"Quantity":1,"Items":["/*"]}}'
3. Capture the Invalidation Id from the response.
4. Poll until Completed:
aws cloudfront get-invalidation \
--distribution-id E1ABC2DEF3GHI4 \
--id <invalidation-id>
POST_VERIFY:
- (pending execution)
COST: Free tier (1 path of 1,000 monthly)
NOTES:
- /* invalidation counts as 1 path regardless of how many objects
the distribution serves. This is the most cost-effective way to
clear all edge cache.
- Propagation typically completes in 30-120 seconds globally.
- Consider versioned filenames (app.<hash>.js) for routine deploys
to avoid invalidation entirely.
Worked example — create-invalidation specific paths (cost advisory)
Worked example — specific-paths invalidation with cost advisory moved verbatim to references/worked-examples.md.
Load it when planning per-path invalidations beyond the free tier.
Worked example — wait-invalidation (COMPLETED)
Worked example — wait-invalidation (COMPLETED) moved verbatim to references/worked-examples.md.
Load it when polling an invalidation to Completed.
Worked example — continuous deployment staging invalidation
Worked example — continuous deployment staging invalidation moved verbatim to references/worked-examples.md.
Load it when invalidating a staging distribution.
Anti-Patterns — NEVER (top mistakes)
NEVER list individual object paths when a wildcard (/* or
/images/*) covers the same set. Each individual path counts
against the 1,000-path free tier; a wildcard counts as ONE path.
500 individual paths = 500 free-tier paths consumed; /* = 1
free-tier path for the same effect.
NEVER reuse a CallerReference across invalidations. CloudFront
treats CallerReference as a deduplication key — a reused value
silently returns the old invalidation without creating a new one.
This is the most common cause of "I invalidated but nothing
happened." Always use a UUID or timestamp.
NEVER rely on invalidation as your primary cache-busting strategy
for routine deploys. Use versioned filenames (app.<hash>.js) so
new deploys are new URLs that CloudFront fetches automatically.
Invalidation is for emergencies, hotfixes to unversioned assets,
and sensitive-data removal. Routine invalidation burns the free
tier and costs $0.005/path beyond 1,000.
NEVER invalidate a distribution whose origin still serves the old
(broken) content. Invalidation clears the edge cache, but the next
request re-fetches from the origin. If the origin has not been
fixed (redeployed, rolled back), the invalidation re-caches the
broken content. Fix the origin first, then invalidate.
NEVER forget to invalidate the staging distribution in a continuous
deployment workflow. The primary and staging distributions have
independent edge caches. Invalidating the primary does NOT clear
the staging cache. If you test on staging and it serves stale
content, the staging distribution needs its own invalidation.
NEVER assume InvalidationStatus: Completed means all users see
fresh content immediately. Completed means CloudFront edge caches
are cleared. End-user browser caches, intermediate CDN caches, and
DNS resolvers may still serve old content. Use short
Cache-Control headers or versioned filenames to address browser
cache staleness.
NEVER use mid-segment wildcards (/images/*/photo.jpg). CloudFront
only supports wildcard * at the END of a path segment. Use
/images/* to match the entire directory tree, or list individual
paths.
NEVER exceed 15 concurrent InProgress invalidations per
distribution. CloudFront returns TooManyInvalidationsInProgress.
Consolidate into fewer wildcard-based batches, or wait for
existing invalidations to complete.
NEVER use invalidation to manage cache behavior for dynamic API
responses. API responses should use Cache-Control: no-cache or
short TTLs in the cache policy. Invalidation is for static assets,
not for clearing dynamic content that changes on every request.
NEVER create an invalidation without first checking the monthly
cumulative path count. If you have already used 950 of your 1,000
free paths, a 200-path invalidation costs $0.75 (150 paths at
$0.005). Track cumulative usage via list-invalidations across
all distributions.
Pre-flight safety checks (run before any remediation CLI)
Pre-flight safety checks (CONFIRMATION GATE, pre-state capture, distribution status, origin health, CallerReference uniqueness, additive-first) moved verbatim to references/diagnostic-commands.md.
Load them before emitting any remediation CLI.
Recent AWS features (2024-2026)
Recent AWS features 2024-2026 (continuous deployment hardening, KeyValueStore, response headers policies, OAC, Metrics, function propagation, S3 Object Lambda) moved verbatim to references/advanced-patterns.md.
Load on demand when an operation involves staging distributions or KVS.
References (load on demand)
- references/advanced-patterns.md — Step 0 invalidation heuristics and recent AWS features moved from SKILL.md
- references/diagnostic-commands.md — live-account pre-flight capture and pre-flight safety checks moved from SKILL.md
- references/error-handling.md — invalidation failure-mode table moved from SKILL.md
- references/worked-examples.md — secondary worked examples (specific paths, wait-invalidation, staging invalidation) moved from SKILL.md; the primary /* example stays in SKILL.md
- references/cache-busting-strategy.md — invalidation vs versioned-filenames decision matrix
- references/path-patterns-and-cost.md — path pattern syntax, cost tables, wildcard optimization, diagnostic quick-reference
Domain
AWS CloudOps / CloudFront Cache Invalidation, Cache-Busting Strategy
& Continuous Deployment.
AWS documentation
1---2name: cloudfront-invalidation-operator3description: 'Operates CloudFront cache invalidation workflows — invalidation creation with path patterns (/* all, /images/* directory, /images/*.css wildcard, single-path), invalidation cost tiering (first 1,000 paths/month free then $0.005 per path), cache-busting strategy (invalidation vs versioned filenames), invalidation status polling (InvalidationStatus: InProgress→Completed), bulk invalidation patterns, continuous deployment staging invalidation, and diagnostic loops (get-invalidation, list-invalidations). Runs deterministic pre-checks (distribution Deployed, caller has cloudfront:CreateInvalidation, path count under free tier, path syntax valid) behind a CONFIRM gate and emits a READY, BLOCKED, or COMPLETED verdict. Use when creating invalidations, waiting for completion, choosing invalidation vs cache-busting, or diagnosing invalidation cost.'4license: Apache-2.05compatibility: Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). No AWS CLI required for offline plan classification. Live-account operations use aws cloudfront create-invalidation, get-invalidation, list-invalidations, get-distribution, list-distributions, get-distribution-config (AWS CLI v2, SSO or key-based credentials).6metadata:7 source: https://skillmd.com/skills/jhkchan/cloudfront-invalidation-operator8 domain: aws-cloudops9 complexity: medium10 requires_llm: 'true'11 phase: '4'12 supports_pipeline: 'true'13 entry_point: 'false'14 family: Networking15 task_type: operate16 skill_class: capability17 lifecycle_status: active18 verdict_shape: READY | BLOCKED | COMPLETED19 when_to_use: Creating a CloudFront cache invalidation (/* all, /images/* directory, /images/*.css wildcard, or single-object path), waiting for an invalidation to reach Completed status, deciding whether to invalidate or use versioned filenames for cache-busting, planning a bulk invalidation that exceeds the 1,000-path free tier, invalidating a staging distribution in a continuous deployment workflow, or diagnosing why an invalidation is stuck InProgress or costs more than expected.20 activation_triggers: invalidate CloudFront cache, CloudFront invalidation, create-invalidation, get-invalidation, InvalidationStatus, InProgress invalidation, cache busting, versioned filenames, CloudFront continuous deployment, staging distribution invalidation, invalidate /*, bulk invalidation, CloudFront edge cache, clear CDN cache, invalidation cost21 invocation_schema: 'Input: either (a) a CloudFront distribution configuration (get-distribution output) plus the intended operation (create-invalidation, wait-invalidation, cost-analysis, compare-strategy, diagnose-invalidation), OR (b) a distribution-id + operation for live-account execution. Output: deterministic OPERATION / VERDICT / PRE_CHECKS / STEPS / POST_VERIFY / NOTES block per invalidation, where VERDICT is one of READY, BLOCKED, COMPLETED.'22 version: 0.1.023 author: Jacky Chan — AWS Community Builder24 keywords: CloudFront, invalidation, cache busting, edge cache, CDN, path pattern, wildcard invalidation, CreateInvalidation, GetInvalidation, InvalidationStatus, continuous deployment, staging distribution, cache policy, versioned filenames, origin, distribution, InProgress, Completed25 tags: aws, cloudfront, networking, cdn, cache, invalidation, operate26---2728# CloudFront Invalidation Operator2930## What this skill does3132Executes CloudFront cache invalidation operations correctly and33cost-effectively. Runs deterministic pre-checks before any34state-changing CLI (distribution is Deployed, caller has35`cloudfront:CreateInvalidation` permission, path patterns are36syntactically valid, path count is under the free-tier threshold or37cost is acknowledged), executes the `create-invalidation` CLI behind38a CONFIRM gate, and verifies the result by polling39`get-invalidation` until `InvalidationStatus: Completed`. Every40invalidation produces a cost note (1-1000 paths free per month, then41$0.005/path) and a cache-busting strategy comparison (invalidation vs42versioned filenames). Continuous deployment distributions route to43the staging distribution for invalidation before promotion.4445## Quick navigation4647| Section | What it covers | When to read it |48|---|---|---|49| **§ Quick reference** | Verdict thresholds (BLOCKED/READY/COMPLETED) + pre-check priority | Before any operation |50| **§ Mindset** | Why invalidation is a blunt tool, the free-tier trap, the cache-busting hierarchy | Understanding the cost model |51| **§ Pre-flight** | Distribution metadata gate — Deployed state, caller IAM, path syntax | Before executing any CLI |52| **§ Process** | Per-operation planning: create, wait, cost-analysis, compare-strategy, diagnose | When choosing which operation to run |53| **§ Output format** | STRICT output contract — OPERATION/VERDICT/PRE_CHECKS/STEPS/POST_VERIFY template | Formatting the response |54| **§ Anti-Patterns** | NEVER list — top mistakes that waste money or leave stale cache | Review before risky operations |55| **§ Pre-flight safety** | Capture pre-state, distribution config verification, cost capture | Defense-in-depth |5657## Quick reference — verdict thresholds5859| Verdict | Trigger condition | Action |60|---|---|---|61| `BLOCKED` | One or more pre-checks failed (distribution not Deployed, caller lacks `cloudfront:CreateInvalidation`, path pattern syntax invalid, continuous deployment primary without staging awareness) | List failures, do NOT execute |62| `READY` | All pre-checks passed; awaiting CONFIRM gate | Emit exact CLI sequence, wait for operator yes |63| `COMPLETED` | Invalidation created and `InvalidationStatus: Completed` confirmed via `get-invalidation` | Emit verification results, cost summary, monitoring plan |6465**Priority order for pre-checks (apply in this sequence, all must pass66for READY):**67681. **Distribution reachability** — distribution exists69 (`get-distribution` does not return `NoSuchResource`), and the70 distribution ID is valid.712. **Distribution is Deployed** — `Status: Deployed` (not72 `InProgress`, `Deleting`, or `Suspended`). Invalidation on a73 non-Deployed distribution may fail or have no effect.743. **Path pattern syntax** — each path starts with `/`, uses75 ASCII-safe characters, and wildcard `*` appears only at the end76 of a path segment (e.g. `/images/*.jpg` is valid;77 `/images/*/header.jpg` is NOT valid).784. **Path count vs free tier** — the first 1,000 invalidation paths79 per month are free; paths beyond 1,000 cost $0.005 each. If the80 path count exceeds 1,000, surface a cost warning in the plan.815. **Caller IAM permission** — the calling identity must have82 `cloudfront:CreateInvalidation` on the distribution ARN. Without83 it, `create-invalidation` returns `AccessDenied`.846. **Continuous deployment awareness** — if the distribution has a85 `ContinuousDeploymentPolicyId`, invalidations should target the86 STAGING distribution for testing before promotion to the primary.877. **CallerRef uniqueness** — `CallerReference` must be unique per88 invalidation. Reusing a CallerReference silently deduplicates89 (returns the existing invalidation without creating a new one).9091**Cost/time baselines (2026):**9293- First 1,000 invalidation paths per month: free (across all94 distributions in the account).95- Paths 1,001+: $0.005 per path per month.96- A single `/*` invalidation counts as ONE path (covers all objects).97- A `/images/*` invalidation also counts as ONE path.98- Listing each object individually (`/index.html`, `/style.css`,99 `/logo.png`) counts as one path EACH — 3 paths for 3 objects.100- Invalidation propagation: typically 10-120 seconds for global101 edge locations. CloudFront does not publish a strict SLA for102 invalidation completion.103- `InvalidationStatus: InProgress` → `Completed` transition: usually104 under 60 seconds for small path counts, up to 10+ minutes for105 large wildcard invalidations.106107## Mindset108109**One-line takeaway:** CloudFront invalidation is a blunt instrument110— `/*` clears everything in one free path, but listing individual111objects burns through the 1,000-path free tier and costs $0.005 per112extra path. Driven by three CloudFront realities:113114- **Versioned filenames beat invalidation for routine deploys.** If115 your CI/CD pipeline renames assets on every build (`app.abc123.js`116 instead of `app.js`), the new file is fetched on first request with117 no invalidation needed. Invalidation is for emergency content118 removal, hotfixes to unversioned assets, or removing sensitive data119 already cached at the edge. Always prefer versioned filenames for120 routine releases.121122- **`/*` is the most cost-effective invalidation.** A single `/*`123 invalidation counts as ONE path (free tier) and invalidates every124 object in the distribution. Listing 500 individual paths consumes125 500 of your 1,000 free paths. If you need to invalidate more than126 ~60% of your site, `/*` is cheaper than per-path invalidation.127128- **Continuous deployment changes the invalidation target.** With a129 CloudFront continuous deployment policy, traffic is split between130 the primary and staging distributions. Invalidation on the primary131 does NOT invalidate the staging distribution's edge cache. You must132 invalidate both (or invalidate staging first, then promote).133134## Pre-flight: distribution metadata gate135136Run before classification. Misclassifying these produces wrong plans.137138**Pagination:** `list-distributions` paginates at 200/page — drain139`--marker`/`--next-marker` to completion. `list-invalidations`140paginates at 100/page.141142Live-account pre-flight (get-distribution capture, list-invalidations history, continuous-deployment policy, monthly path-count tally) moved verbatim to [references/diagnostic-commands.md](references/diagnostic-commands.md).143Load them before classifying an operation on a live account.144145**Malformed input:** if the input is invalid or missing required146fields, emit `VERDICT: ERROR` with `REASON: Distribution147configuration is not valid or is missing required fields — cannot148plan.` and `REMEDIATION: Re-fetch with aws cloudfront get-distribution149--id <id> --output json and re-plan.`150151| Distribution attribute | Effect on operation |152|---|---|153| `Status: InProgress` | BLOCKED — distribution update in flight. Wait for `Deployed`. |154| `Status: Deployed` | OK — distribution is live, invalidation can proceed. |155| `Status: Suspended` | BLOCKED — distribution is suspended. Restore via `update-distribution` with `Enabled: true`. |156| `Status: Deleting` | BLOCKED — distribution being deleted. No invalidation possible. |157| `Enabled: false` | BLOCKED — distribution disabled. Invalidation may fail or have no effect. |158| `ContinuousDeploymentPolicyId` present | INFO — continuous deployment active. Invalidation should target staging first, then primary on promotion. |159| Path count > 1,000 (monthly cumulative) | ADVISORY — paths beyond 1,000 cost $0.005 each. Surface cost in the plan. |160| Path contains `*` mid-segment | BLOCKED — wildcard only valid at end of a path segment. |161| `CallerReference` collides with existing | BLOCKED — CallerReference must be unique. Generate a new one. |162163## Process — operation planning (apply in order)164165### Step 0: Expert heuristic — non-obvious CloudFront behaviors166167Step 0 expert heuristics (/* path counting, versioned filenames, CallerReference dedup, wildcard scope, browser cache, continuous-deployment targets, origin rollback, per-edge status, 3,000-path limit, function propagation, origin-type invariance) moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md).168Load on demand before producing the operation plan.169170### Step 1: Pre-check gate — BLOCKED if any check fails171172Run ALL pre-checks for the chosen operation. If ANY fails, the verdict173is BLOCKED with the failed checks in PRE_CHECKS. Do NOT execute.174175**For ALL operations:**1761. Distribution exists (`get-distribution` does not return177 `NoSuchResource`).1782. Distribution `Status: Deployed`.1793. `DistributionConfig.Enabled: true`.180181**For create-invalidation:**1824. Path patterns are syntactically valid (start with `/`, wildcard183 only at segment end, no more than 3,000 paths per batch).1845. Calling identity has `cloudfront:CreateInvalidation` on the185 distribution ARN.1866. `CallerReference` is unique (not in recent `list-invalidations`).1877. (Advisory) Path count + monthly cumulative > 1,000: surface cost188 warning.189190**For wait-invalidation (read-only):**1914. `get-invalidation --id <id>` returns a valid invalidation with192 `InvalidationStatus`.1935. (Advisory) If `InvalidationStatus: InProgress` for > 15 minutes,194 surface a warning (typically completes in under 5 minutes).195196**For cost-analysis (read-only):**1974. `list-invalidations` for all distributions this month — sum198 `Paths.Quantity` across all invalidations.1995. Compare cumulative path count vs the 1,000-path free tier.200201**For compare-strategy (read-only):**2024. Analyze the deployment workflow: are assets versioned? Is the203 origin S3 or custom? What is the typical change frequency?2045. Recommend invalidation vs versioned filenames based on workflow.205206**For diagnose-invalidation (read-only):**2074. Read `get-invalidation`, `list-invalidations`, distribution config,208 and the failure-mode table to identify why an invalidation is209 stuck, not working, or unexpectedly expensive.210211Invalidation failure-mode table (AccessDenied, InvalidArgument, TooManyInvalidationsInProgress, CallerReference collisions, staging failures, cost surprises) moved verbatim to [references/error-handling.md](references/error-handling.md).212Load it during diagnose-invalidation operations.213214### Step 2: READY — emit operation plan215216If all pre-checks pass, emit `VERDICT: READY` with the exact CLI217sequence and the CONFIRM gate. The plan includes:218219- The exact AWS CLI command with all flags populated from the220 distribution configuration.221- The expected path count and cost (free tier or $0.005/path beyond222 1,000).223- The `CallerReference` value (unique per invalidation).224- The expected side-effects (edge cache cleared for matching paths,225 next request fetches fresh content from origin).226- The CONFIRM gate prompt.227- The verification step (`get-invalidation` polling until Completed).228229### Step 3: Execute behind CONFIRM gate230231- **MANDATORY CONFIRMATION GATE.** Before any state-changing CLI232 (`create-invalidation`), emit:233 `CONFIRM: About to create a CloudFront invalidation on distribution234 <id> (domain <domain>). Paths: <path-list-or-pattern>. Estimated235 cost: <$X or "free tier">. This will clear edge cache for matching236 paths. Proceed? (yes/no)`. Do NOT execute until the operator237 confirms.238- Capture pre-state for audit: `aws cloudfront list-invalidations239 --distribution-id <id> --max-items 5 --output json >240 /tmp/<id>-invalidations-pre-$(date +%s).json`.241- Execute the CLI. `create-invalidation` returns immediately with an242 `Invalidation` object containing the `Id` and243 `InvalidationStatus: InProgress`.244- For continuous deployment: execute on the STAGING distribution245 first (if testing), then the PRIMARY distribution after promotion.246247### Step 4: Post-verification — COMPLETED248249After the CLI completes, run post-verification. ALL checks must pass250for `COMPLETED`.2512521. `get-invalidation --distribution-id <id> --id <invalidation-id>`253 — confirm `InvalidationStatus: Completed`.2542. `list-invalidations --distribution-id <id>` — confirm the new255 invalidation appears in the list with `Completed` status.2563. Spot-check: `curl -I https://<domain>/<path>` — confirm257 `X-Cache: RefreshHit from CloudFront` (re-fetched from origin) or258 `X-Cache: Miss from CloudFront` (first fetch after invalidation).2594. (Continuous deployment) Confirm the staging distribution260 invalidation (if applicable) is also Completed.2615. Cost verification: confirm the path count billed matches the plan262 (first 1,000 free, $0.005/path beyond).263264If ANY verification fails, emit `VERDICT: ERROR` with the failure265details — do not claim COMPLETED.266267## Output format (STRICT output contract — per operation)268269```text270OPERATION: <create-invalidation | wait-invalidation | cost-analysis | compare-strategy | diagnose-invalidation>271VERDICT: READY | BLOCKED | COMPLETED272TARGET: <distribution-id> (domain: <domain-name>, account <account>)273PRE_CHECKS:274 - [PASS] <check description>275 - [FAIL] <check description> — <reason>276STEPS:277 1. <CLI command with flags populated>278 2. <wait / monitoring command>279 3. <next step>280POST_VERIFY:281 - [PASS] <verification description>282 - [FAIL] <verification description> — <reason>283COST: <free tier | $X.XX for N paths beyond free tier>284NOTES: <cache-busting recommendation, monitoring, caveats>285```286287### Worked example — create-invalidation /* (all paths)288289```text290OPERATION: create-invalidation291VERDICT: READY292TARGET: E1ABC2DEF3GHI4 (domain: d111111abcdef8.cloudfront.net,293 account 111111111111)294PRE_CHECKS:295 - [PASS] Distribution exists296 - [PASS] Status: Deployed297 - [PASS] Enabled: true298 - [PASS] Path pattern: /* (valid — single wildcard path)299 - [PASS] Calling role has cloudfront:CreateInvalidation on300 arn:aws:cloudfront::111111111111:distribution/E1ABC2DEF3GHI4301 - [PASS] CallerReference: inv-20260810-001 (unique)302 - [INFO] Path count: 1 (free tier — 1 of 1,000 monthly paths used)303STEPS:304 1. CONFIRM: About to create a CloudFront invalidation on305 distribution E1ABC2DEF3GHI4 (d111111abcdef8.cloudfront.net).306 Paths: /* (all objects). Cost: free tier. This will clear edge307 cache for ALL objects globally. Next requests will fetch from308 origin. Proceed? (yes/no)309 2. aws cloudfront create-invalidation \310 --distribution-id E1ABC2DEF3GHI4 \311 --invalidation-batch '{"CallerReference":"inv-20260810-001",312 "Paths":{"Quantity":1,"Items":["/*"]}}'313 3. Capture the Invalidation Id from the response.314 4. Poll until Completed:315 aws cloudfront get-invalidation \316 --distribution-id E1ABC2DEF3GHI4 \317 --id <invalidation-id>318POST_VERIFY:319 - (pending execution)320COST: Free tier (1 path of 1,000 monthly)321NOTES:322 - /* invalidation counts as 1 path regardless of how many objects323 the distribution serves. This is the most cost-effective way to324 clear all edge cache.325 - Propagation typically completes in 30-120 seconds globally.326 - Consider versioned filenames (app.<hash>.js) for routine deploys327 to avoid invalidation entirely.328```329330### Worked example — create-invalidation specific paths (cost advisory)331332Worked example — specific-paths invalidation with cost advisory moved verbatim to [references/worked-examples.md](references/worked-examples.md).333Load it when planning per-path invalidations beyond the free tier.334335### Worked example — wait-invalidation (COMPLETED)336337Worked example — wait-invalidation (COMPLETED) moved verbatim to [references/worked-examples.md](references/worked-examples.md).338Load it when polling an invalidation to Completed.339340### Worked example — continuous deployment staging invalidation341342Worked example — continuous deployment staging invalidation moved verbatim to [references/worked-examples.md](references/worked-examples.md).343Load it when invalidating a staging distribution.344345## Anti-Patterns — NEVER (top mistakes)346347- NEVER list individual object paths when a wildcard (`/*` or348 `/images/*`) covers the same set. Each individual path counts349 against the 1,000-path free tier; a wildcard counts as ONE path.350 500 individual paths = 500 free-tier paths consumed; `/*` = 1351 free-tier path for the same effect.352353- NEVER reuse a `CallerReference` across invalidations. CloudFront354 treats CallerReference as a deduplication key — a reused value355 silently returns the old invalidation without creating a new one.356 This is the most common cause of "I invalidated but nothing357 happened." Always use a UUID or timestamp.358359- NEVER rely on invalidation as your primary cache-busting strategy360 for routine deploys. Use versioned filenames (`app.<hash>.js`) so361 new deploys are new URLs that CloudFront fetches automatically.362 Invalidation is for emergencies, hotfixes to unversioned assets,363 and sensitive-data removal. Routine invalidation burns the free364 tier and costs $0.005/path beyond 1,000.365366- NEVER invalidate a distribution whose origin still serves the old367 (broken) content. Invalidation clears the edge cache, but the next368 request re-fetches from the origin. If the origin has not been369 fixed (redeployed, rolled back), the invalidation re-caches the370 broken content. Fix the origin first, then invalidate.371372- NEVER forget to invalidate the staging distribution in a continuous373 deployment workflow. The primary and staging distributions have374 independent edge caches. Invalidating the primary does NOT clear375 the staging cache. If you test on staging and it serves stale376 content, the staging distribution needs its own invalidation.377378- NEVER assume `InvalidationStatus: Completed` means all users see379 fresh content immediately. Completed means CloudFront edge caches380 are cleared. End-user browser caches, intermediate CDN caches, and381 DNS resolvers may still serve old content. Use short382 `Cache-Control` headers or versioned filenames to address browser383 cache staleness.384385- NEVER use mid-segment wildcards (`/images/*/photo.jpg`). CloudFront386 only supports wildcard `*` at the END of a path segment. Use387 `/images/*` to match the entire directory tree, or list individual388 paths.389390- NEVER exceed 15 concurrent InProgress invalidations per391 distribution. CloudFront returns `TooManyInvalidationsInProgress`.392 Consolidate into fewer wildcard-based batches, or wait for393 existing invalidations to complete.394395- NEVER use invalidation to manage cache behavior for dynamic API396 responses. API responses should use `Cache-Control: no-cache` or397 short TTLs in the cache policy. Invalidation is for static assets,398 not for clearing dynamic content that changes on every request.399400- NEVER create an invalidation without first checking the monthly401 cumulative path count. If you have already used 950 of your 1,000402 free paths, a 200-path invalidation costs $0.75 (150 paths at403 $0.005). Track cumulative usage via `list-invalidations` across404 all distributions.405406## Pre-flight safety checks (run before any remediation CLI)407408Pre-flight safety checks (CONFIRMATION GATE, pre-state capture, distribution status, origin health, CallerReference uniqueness, additive-first) moved verbatim to [references/diagnostic-commands.md](references/diagnostic-commands.md).409Load them before emitting any remediation CLI.410411## Recent AWS features (2024-2026)412413Recent AWS features 2024-2026 (continuous deployment hardening, KeyValueStore, response headers policies, OAC, Metrics, function propagation, S3 Object Lambda) moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md).414Load on demand when an operation involves staging distributions or KVS.415416## References (load on demand)417418- [references/advanced-patterns.md](references/advanced-patterns.md) — Step 0 invalidation heuristics and recent AWS features moved from SKILL.md419- [references/diagnostic-commands.md](references/diagnostic-commands.md) — live-account pre-flight capture and pre-flight safety checks moved from SKILL.md420- [references/error-handling.md](references/error-handling.md) — invalidation failure-mode table moved from SKILL.md421- [references/worked-examples.md](references/worked-examples.md) — secondary worked examples (specific paths, wait-invalidation, staging invalidation) moved from SKILL.md; the primary /* example stays in SKILL.md422- [references/cache-busting-strategy.md](references/cache-busting-strategy.md) — invalidation vs versioned-filenames decision matrix423- [references/path-patterns-and-cost.md](references/path-patterns-and-cost.md) — path pattern syntax, cost tables, wildcard optimization, diagnostic quick-reference424425## Domain426427AWS CloudOps / CloudFront Cache Invalidation, Cache-Busting Strategy428& Continuous Deployment.429430## AWS documentation431432- **CloudFront Developer Guide** — https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/433- **Invalidating files** — https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html434- **CreateInvalidation API** — https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CreateInvalidation.html435- **GetInvalidation API** — https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_GetInvalidation.html436- **Continuous deployment** — https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/continuous-deployment.html437- **CloudFront pricing** — https://aws.amazon.com/cloudfront/pricing/438- **CloudFront CLI Reference** — https://docs.aws.amazon.com/cli/latest/reference/cloudfront/439- **Cache policies** — https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/controlling-the-cache-key.html