[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7A4P6MPD9FQ7CRYVTW4XQCP":3,"skill-same:01M7A4P6MPD9FQ7CRYVTW4XQCP":141},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":45,"commitSha":46,"skillDirectory":47,"forksCount":48,"repositoryHtmlUrl":49,"repositoryHomepageUrl":6,"ownerHtmlUrl":50,"ownerBlogUrl":6,"ownerDescription":51,"updatedAt":52,"install":53,"resources":66},"01M7A4P6MPD9FQ7CRYVTW4XQCP","cloudfront-502-troubleshooter",null,"Diagnoses CloudFront 502 and 504 errors via a fourteen-layer decision tree covering origin connection timeouts to ALB\u002FNLB\u002FS3 custom origins, SSL\u002FTLS protocol and cipher mismatch between CloudFront and the origin, origin response too large, custom origin header validation failure, Lambda@Edge function runtime errors, S3 origin access control (OAC) misconfiguration, multi-origin failover, geographic restriction blocking, field-level encryption errors, response timeout (504), origin shield routing, distribution deployment state, and cached error responses where a Custom Error Response with high TTL hides a transient origin failure. Walks x-edge-result-type and x-cache headers, origin probe results, and distribution config to a verified root cause. Emits ROOT_CAUSE_IDENTIFIED or INSUFFICIENT_DATA with the specific failure layer and the probe output that confirms it.","jhkchan\u002Faws-agent-skills","jhkchan","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1083902?v=4","01M7A2SVQYP9GQTPTDXP5JKYQ4","Jacky Chan","01M7A2SVS117YWCTZABB75HZR1",4,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: cloudfront-502-troubleshooter\ndescription: Diagnoses CloudFront 502 and 504 errors via a fourteen-layer decision tree covering origin connection timeouts to ALB\u002FNLB\u002FS3 custom origins, SSL\u002FTLS protocol and cipher mismatch between CloudFront and the origin, origin response too large, custom origin header validation failure, Lambda@Edge function runtime errors, S3 origin access control (OAC) misconfiguration, multi-origin failover, geographic restriction blocking, field-level encryption errors, response timeout (504), origin shield routing, distribution deployment state, and cached error responses where a Custom Error Response with high TTL hides a transient origin failure. Walks x-edge-result-type and x-cache headers, origin probe results, and distribution config to a verified root cause. Emits ROOT_CAUSE_IDENTIFIED or INSUFFICIENT_DATA with the specific failure layer and the probe output that confirms it.\nlicense: Apache-2.0\ncompatibility: Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). Offline diagnosis works from pasted CloudFront access-log excerpts, response headers, and distribution config JSON. Live-account diagnosis uses aws cloudfront get-distribution-config \u002F get-distribution \u002F list-origin-access-controls, aws logs filter-log-events on the us-east-1 CloudFront and Lambda@Edge log groups, aws s3api get-bucket-policy \u002F head-object, aws elbv2 describe-load-balancers \u002F...\nmetadata:\n  domain: aws-cloudops\n  complexity: high\n  requires_llm: 'true'\n  phase: '2'\n  supports_pipeline: 'true'\n  entry_point: 'false'\n  family: Networking\n  task_type: troubleshoot\n  skill_class: capability\n  lifecycle_status: active\n  verdict_shape: ROOT_CAUSE_IDENTIFIED | INSUFFICIENT_DATA\n  when_to_use: Diagnosing a CloudFront distribution returning 502 Bad Gateway or 504 Gateway Timeout — including origin connection failures, TLS handshake errors, Lambda@Edge runtime exceptions, S3 OAC misconfiguration, failover routing, geographic blocks, field-level encryption failures, origin-shield errors, deployment-state artefacts, or stale error-cache entries hiding a now-recovered origin.\n  when_not_to_use: Cache hit ratio \u002F stale content without 502\u002F504 (use cloudfront-cache-troubleshooter), cost analysis (use cloudfront-cost-optimizer), distribution creation (use cloudfront-distribution-deployer), or WAF 403 blocks (use wafv2-web-acl-deployer). This skill is scoped to 502\u002F504-class origin and edge failures.\n  activation_triggers: CloudFront 502, CloudFront 504, CloudFront Bad Gateway, CloudFront origin connection failed, CloudFront TLS handshake failure, CloudFront Lambda@Edge error, CloudFront OAC 502, CloudFront failover 502, CloudFront geographic block, CloudFront origin shield 502, CloudFront cached 502, troubleshoot CloudFront 502\n  invocation_schema: 'Input: either (a) a symptom description (502\u002F504 status, the x-edge-result-type and x-cache values from access logs, viewer error message) optionally paired with the distribution configuration and curl reproduction, OR (b) a DistributionId plus viewer context for live-account diagnosis. Output: a deterministic TARGET \u002F VERDICT \u002F REASON \u002F LAYER \u002F EVIDENCE \u002F REMEDIATION block where VERDICT ∈ {ROOT_CAUSE_IDENTIFIED, INSUFFICIENT_DATA} and LAYER ∈ {ORIGIN_CONNECTION_TIMEOUT, ORIGIN_TLS_PROTOCOL_MISMATCH, ORIGIN_TLS_CIPHER_MISMATCH, ORIGIN_RESPONSE_TOO_LARGE, CUSTOM_HEADER_VALIDATION, LAMBDA_AT_EDGE_ERROR, OAC_MISCONFIGURATION, FAILOVER_MISCONFIGURATION, GEO_RESTRICTION_BLOCKING, FIELD_LEVEL_ENCRYPTION_ERROR, ORIGIN_RESPONSE_TIMEOUT, ORIGIN_SHIELD_MISCONFIGURATION, DISTRIBUTION_NOT_DEPLOYED, CACHED_ERROR_RESPONSE, UNKNOWN}.'\n  invocation_example: '# Minimal valid input (offline symptom classification):\n\n    Symptom: \"CloudFront distribution d111111abcdef8.cloudfront.net\n\n    returns HTTP 502 to all viewers on \u002Fapi\u002F* since 14:10 UTC.\n\n    Origin is an ALB in us-east-1.\"\n\n    DistributionId: E1Q2W3R4Y5Z6A7\n\n    DomainName: d111111abcdef8.cloudfront.net\n\n    Origin: api.alb.example.com (ALB, HTTPS-only)\n\n    OriginProtocolPolicy: https-only\n\n    x-edge-result-type from logs: Error\n\n    x-cache from logs: Error from origin\n\n    Last deployment: 1 hour ago (added OriginProtocolPolicy: https-only)\n\n    '\n  version: 0.1.0\n  author: Jacky Chan — AWS Community Builder\n  keywords: CloudFront, 502, 504, Bad Gateway, Gateway Timeout, origin connection timeout, TLS negotiation failure, SSL protocol mismatch, cipher suite mismatch, Lambda@Edge, Origin Access Control, OAC, multi-origin failover, geographic restriction, field-level encryption, origin shield, cached error response, troubleshoot CloudFront\n  tags: cloudfront, networking, cdn, troubleshooting, 502, tls, lambda-at-edge, oac\n---\n\n# CloudFront 502 Troubleshooter\n\n## Quick start\n\n- **Symptom -> layer map (first plausible match drives the first probe):**\n  a fresh `502` after a config deploy -> LAMBDA_AT_EDGE_ERROR \u002F\n  CUSTOM_HEADER_VALIDATION \u002F ORIGIN_TLS_PROTOCOL_MISMATCH; `502` only\n  from one edge POP -> ORIGIN_SHIELD_MISCONFIGURATION; `504` after N\n  seconds -> ORIGIN_RESPONSE_TIMEOUT or ORIGIN_CONNECTION_TIMEOUT;\n  `502` from S3 origin only -> OAC_MISCONFIGURATION; `502` from one\n  country -> GEO_RESTRICTION_BLOCKING; intermittent 502 lingering after\n  origin recovery -> CACHED_ERROR_RESPONSE.\n- **Read `x-cache` and `x-edge-result-type` before guessing.**\n  `x-cache: Error from cloudfront` = edge produced the 502 (Lambda@Edge,\n  FLE, geo, error cache); `x-cache: Error from origin` = origin\n  returned 5xx to CF. The tree forks at this single field.\n- **Reproduce from outside the cache first.** A `curl -H\n  'Cache-Control: no-cache'` forces a fresh origin fetch. If the 502\n  disappears, the cause is CACHED_ERROR_RESPONSE, not the live origin.\n- **Probe the origin directly with the exact viewer request.** `curl\n  --resolve \u003Corigin>:443:\u003Cip>` with the same Host, protocol, path. A\n  502 here proves origin-side fault; a 200 here proves the failure is\n  between CF and the origin.\n- **A new 502 that appears immediately after a distribution deploy is\n  almost always the deploy, not the origin.** Check `Status: InProgress`\n  first; mixed POP results during propagation are expected.\n\n## Mindset\n\nA CloudFront 502 is a transport- or transaction-layer failure between\nthe edge POP and the origin (or between the viewer and the edge when\nLambda@Edge fails). The body of the 502 page is generic; the\nload-bearing evidence lives in `x-edge-result-type`, `x-cache`, and\n`x-amz-cf-pop` of the access log and in the origin's own response\nwhen probed directly. Senior CDN engineers start with the access log\nrow for a failing request, not the distribution config. The config\nnarrows the search; the log row identifies the layer.\n\n## Philosophy\n\nSenior-engineer philosophy (edge vs origin 502, TLS mismatch, silent OAC failures, error-cache TTL) moved verbatim to [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md).\nLoad on demand when a 502 looks like an origin fault but the evidence points elsewhere.\n\n## Pre-flight: distribution state and gather-info gate\n\nPre-flight gather-info command listing (config, status, logs, viewer curl, origin probe) moved verbatim to [references\u002Fdiagnostic-commands.md](references\u002Fdiagnostic-commands.md).\nRun these read-only probes before any symptom-specific branch of the tree.\n\n| `Status` | Effect on diagnosis |\n|---|---|\n| `Deployed` | Proceed with symptom-driven diagnosis. |\n| `InProgress` | Config update is propagating (5-15 min). Mixed POP behaviour is expected. Wait before drawing conclusions. |\n| `InProgress` > 30 minutes | Stuck deploy; open a Support case. |\n\nThe load-bearing access-log fields for 502 diagnosis: `x-edge-result-type`\n(`Error` vs `FunctionExecutionError` vs `LimitExceeded`),\n`x-edge-response-result-type`, `x-cache` (`Error from cloudfront` vs\n`Error from origin`), `ssl-protocol` \u002F `ssl-cipher` (viewer-side only),\n`fle-status`, `time-taken`.\n\nIf the input is malformed (missing DistributionId, no symptom\ndescription, no curl reproduction or access-log row), emit:\n\n```text\nTARGET: \u003Cdistribution-id or unknown>\nVERDICT: INSUFFICIENT_DATA\nREASON: Input is missing required context — at minimum a symptom\n  description (HTTP 502\u002F504 status) and the DistributionId. Access-log\n  excerpts or a curl reproduction are required for high-confidence\n  layer identification.\nLAYER: UNKNOWN\nEVIDENCE:\n  - Missing: \u003Clist specific missing fields>\nREMEDIATION: Re-prompt the operator for: (1) DistributionId and failing\n  path; (2) curl reproduction with response headers; (3) at least one\n  access-log row showing the 502\u002F504; (4) recent deployment timestamps.\n```\n\n## Quick reference — symptom triage table\n\n| Symptom \u002F log signal | Most likely layer | First probe |\n|---|---|---|\n| `x-cache: Error from origin` + origin unreachable | ORIGIN_CONNECTION_TIMEOUT | `elbv2 describe-target-health` (ALB) or `s3api head-object` (S3) |\n| `x-cache: Error from origin` + handshake errors | ORIGIN_TLS_PROTOCOL_MISMATCH \u002F ORIGIN_TLS_CIPHER_MISMATCH | `openssl s_client -connect origin:443` from edge-like client |\n| 502 only on responses > 10 MB | ORIGIN_RESPONSE_TOO_LARGE | Origin `Content-Length` vs CF payload cap |\n| 502 begins after adding `OriginCustomHeader` | CUSTOM_HEADER_VALIDATION | Compare header value at origin vs config |\n| `x-edge-result-type: FunctionExecutionError` | LAMBDA_AT_EDGE_ERROR | `logs filter-log-events` on `\u002Faws\u002Flambda\u002Fus-east-1.\u003Cfn>` in us-east-1 |\n| 502 only on S3 origin, ALB origin fine | OAC_MISCONFIGURATION | `s3api get-bucket-policy` + verify `cloudfront:GetResource` principal |\n| 502 when primary fails; secondary never reached | FAILOVER_MISCONFIGURATION | `get-distribution-config` OriginGroups + behaviour `TargetOriginId` |\n| 502 only from one country; `x-edge-result-type: LimitExceeded` | GEO_RESTRICTION_BLOCKING | `get-distribution-config` Restrictions.GeoRestriction |\n| 502 with field-level encryption recently enabled | FIELD_LEVEL_ENCRYPTION_ERROR | Verify public key, query profile, content-type |\n| `504` consistently after N seconds of TTFB | ORIGIN_RESPONSE_TIMEOUT | Origin app logs; curl TTFB measurement |\n| 502 only when OriginShield enabled | ORIGIN_SHIELD_MISCONFIGURATION | `get-distribution-config` OriginShield config |\n| `Status: InProgress`; mixed results across POPs | DISTRIBUTION_NOT_DEPLOYED | `get-distribution` Status, LastModifiedTime |\n| Origin recovered but 502 persists for minutes | CACHED_ERROR_RESPONSE | `Cache-Control` \u002F `age` header; Custom Error Response TTL |\n\n## Process — Diagnostic decision tree\n\nSymptom-driven. Each layer ends with a positive root-cause confirmation\n(a failing probe that matches the symptom) or a pass that moves to the\nnext layer. **Never emit ROOT_CAUSE_IDENTIFIED without a failing probe\nthat matches the symptom.**\n\n### Step 0: Non-obvious behaviours that change diagnosis\n\nStep 0 non-obvious behaviours (log region, Origin Shield IP ranges, failover wiring, OAC principal, error cache, FLE, InProgress) moved verbatim to [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md).\nLoad on demand when the obvious layer does not match the symptom.\n\n### Step 1: Symptom entry — pick the diagnostic branch\n\n| Symptom | Branch |\n|---|---|\n| `x-edge-result-type: FunctionExecutionError` | Step 4 — Lambda@Edge |\n| `x-edge-result-type: LimitExceeded` | Step 9 (geo) or WAF (out of scope) |\n| `x-cache: Error from cloudfront` + fresh deploy | Step 5 (custom header) or Step 7 (OAC) |\n| `x-cache: Error from origin` + ALB\u002FNLB origin | Step 2 (connection) |\n| `x-cache: Error from origin` + S3 origin | Step 7 (OAC) |\n| `x-cache: Error from origin` + TLS handshake errors | Step 3 (TLS) |\n| `504` consistently after N seconds | Step 11 (response timeout) |\n| 502 only from specific country | Step 9 (geo restriction) |\n| 502 lingers after origin recovered | Step 14 (cached error) |\n| 502 with FLE recently enabled | Step 10 (FLE) |\n| None of the above | Step 15 (escalate) |\n\n### Step 2: ORIGIN_CONNECTION_TIMEOUT — origin unreachable\n\nSymptom: `x-cache: Error from origin`, origin's own access log shows no\nmatching request (connection never established).\n\n```bash\naws cloudfront get-distribution-config --id \u003Cid> --output json | \\\n  jq '.DistributionConfig.Origins.Items[].DomainName'\n\naws elbv2 describe-target-health --target-group-arn \u003Carn> --output json\n```\n\nIf `target-health` returns no healthy targets, **ROOT_CAUSE_IDENTIFIED**\nwith `LAYER: ORIGIN_CONNECTION_TIMEOUT`. For S3 origins, a 502 usually\nmeans OAC (Step 7), not connection failure — S3 is highly available.\n\n### Step 3: ORIGIN_TLS_PROTOCOL_MISMATCH \u002F ORIGIN_TLS_CIPHER_MISMATCH\n\nSymptom: `x-cache: Error from origin`, origin's access log shows zero\nmatching requests (handshake never completed). Often after a config\nchange to `OriginProtocolPolicy: https-only`.\n\n```bash\naws cloudfront get-distribution-config --id \u003Cid> --output json | \\\n  jq '.DistributionConfig.Origins.Items[] |\n      {DomainName, OriginProtocolPolicy, OriginSslProtocols}'\n\nopenssl s_client -connect \u003Corigin>:443 -servername \u003Corigin> -tls1_2 2>&1 | head -40\nopenssl s_client -connect \u003Corigin>:443 -servername \u003Corigin> -tls1_3 2>&1 | head -40\n```\n\n| Probe result | Layer |\n|---|---|\n| `OriginProtocolPolicy: https-only`, origin listens HTTP only | ORIGIN_TLS_PROTOCOL_MISMATCH |\n| `OriginSslProtocols: [TLSv1.2]`, origin supports TLSv1.0 \u002F TLSv1.1 only | ORIGIN_TLS_PROTOCOL_MISMATCH |\n| Cipher suite negotiation fails (`no shared cipher`) | ORIGIN_TLS_CIPHER_MISMATCH |\n| Origin certificate expired or untrusted chain | ORIGIN_TLS_PROTOCOL_MISMATCH (cert validation) |\n\nFix: align `OriginProtocolPolicy` with what the origin serves, and\nensure `OriginSslProtocols` includes at least one protocol the origin\nsupports.\n\n### Step 4: LAMBDA_AT_EDGE_ERROR — function runtime failure\n\nSymptom: `x-edge-result-type: FunctionExecutionError`. The function\n(viewer-request \u002F origin-request \u002F origin-response \u002F viewer-response)\nthrew an unhandled exception or exceeded its timeout cap.\n\n```bash\naws cloudfront get-distribution-config --id \u003Cid> --output json | \\\n  jq '.DistributionConfig.CacheBehaviors.Items[].LambdaFunctionAssociations'\n\n# Logs in us-east-1 ONLY for Lambda@Edge\naws logs filter-log-events \\\n  --log-group-name \u002Faws\u002Flambda\u002Fus-east-1.\u003Cfunction-name> \\\n  --start-time $(date -d '-30 minutes' +%s)000 \\\n  --filter-pattern '\"ERROR\" OR \"Task timed out\" OR \"Unhandled\"' \\\n  --region us-east-1 --output json\n```\n\n| Pattern | Cause |\n|---|---|\n| Function throws on specific request shape | Bad header parsing, undefined field, large payload |\n| `Task timed out` | Function exceeds 5s (viewer) or 30s (origin) cap |\n| Function size > 1 MB (viewer) \u002F 50 MB (origin) | Exceeds Lambda@Edge size cap; deploy fails |\n| 502 only on \u002Fspecific-path | Function logic branches on URI; one branch throws |\n| Function references `process.env.X` | Lambda@Edge does NOT support env vars; always undefined |\n\nFix: fix the function code, redeploy, and publish a new version ARN.\n\n### Step 5: CUSTOM_HEADER_VALIDATION — origin rejects custom header\n\nSymptom: `x-cache: Error from origin`, recent edit to\n`OriginCustomHeader`. Origin's WAF \u002F auth layer returns 4xx\u002F5xx because\nof header value mismatch.\n\n```bash\naws cloudfront get-distribution-config --id \u003Cid> --output json | \\\n  jq '.DistributionConfig.Origins.Items[].CustomHeaders'\n```\n\nIf the origin expects a different value or header name,\n**ROOT_CAUSE_IDENTIFIED** with `LAYER: CUSTOM_HEADER_VALIDATION`. Align\nthe value in the distribution config OR update the origin's auth module.\n\n### Step 6: ORIGIN_RESPONSE_TOO_LARGE — payload cap exceeded\n\nSymptom: 502 only on large responses.\n\n```bash\ncurl -sv --resolve \u003Corigin>:443:\u003Cip> https:\u002F\u002F\u003Corigin>\u002F\u003Clarge-path> \\\n  -o \u002Fdev\u002Fnull -w '%{size_download} %{http_code}\\n'\n```\n\nIf `size_download` consistently hits a cap and CF truncates with 502,\n**ROOT_CAUSE_IDENTIFIED** with `LAYER: ORIGIN_RESPONSE_TOO_LARGE`. Fix:\npaginate, use range requests, or move to S3 with byte-range serving.\n\n### Step 7: OAC_MISCONFIGURATION — S3 origin access control\n\nSymptom: `x-cache: Error from origin` for S3 origin; bucket policy\nrecently edited or migrated OAI -> OAC.\n\n```bash\naws cloudfront get-distribution-config --id \u003Cid> --output json | \\\n  jq '.DistributionConfig.Origins.Items[] |\n      {DomainName, S3OriginConfig, OriginAccessControlId}'\n\naws cloudfront list-origin-access-controls --output json\naws s3api get-bucket-policy --bucket \u003Cbucket> --output json\n```\n\n| Pattern | Cause |\n|---|---|\n| Bucket policy grants legacy OAI (`CanonicalUser`), CF uses OAC | Principal mismatch; S3 returns 403 to CF |\n| OAC `SigningBehavior: always`, bucket policy lacks `cloudfront:GetResource` | S3 rejects the signed request |\n| Bucket policy restricts by `aws:SourceIp`; CF IPs not allowed | S3 denies |\n| Migrated OAI -> OAC, bucket policy not updated | Policy still references the OAI principal |\n\nFix: update the bucket policy to grant the OAC principal\n(`Service: cloudfront.amazonaws.com`) with `AWS:SourceArn` equal to the\ndistribution ARN.\n\n### Step 8: FAILOVER_MISCONFIGURATION — multi-origin routing\n\nSymptom: 502 when primary fails; secondary never receives traffic.\n\n```bash\naws cloudfront get-distribution-config --id \u003Cid> --output json | \\\n  jq '.DistributionConfig.OriginGroups.Items[] |\n      {Id, FailoverCriteria, Members}'\n# Verify the behaviour points at the group, not the single origin\njq '.DistributionConfig.CacheBehaviors.Items[].TargetOriginId'\n```\n\n| Pattern | Cause |\n|---|---|\n| Behaviour `TargetOriginId` is the primary origin, not the group | Failover never triggers |\n| `FailoverCriteria.StatusCodes` excludes the 5xx primary returns | Group considers primary healthy |\n| Secondary origin unreachable | Failover triggers but secondary also fails |\n\n### Step 9: GEO_RESTRICTION_BLOCKING — geographic block\n\nSymptom: 502 \u002F 403 only from one country. `x-edge-result-type: LimitExceeded`.\n\n```bash\naws cloudfront get-distribution-config --id \u003Cid> --output json | \\\n  jq '.DistributionConfig.Restrictions.GeoRestriction'\n```\n\nIf the failing viewer's country is on the wrong side of a `whitelist` or\n`blacklist`, **ROOT_CAUSE_IDENTIFIED** with\n`LAYER: GEO_RESTRICTION_BLOCKING`. Note: CF returns 403 for geo blocks,\nbut a Custom Error Response can map this to 502 if misconfigured.\n\n### Step 10: FIELD_LEVEL_ENCRYPTION_ERROR — FLE failure\n\nSymptom: 502 with FLE recently enabled. Access log shows\n`fle-status: error` or empty `fle-encrypted-fields`.\n\n| Pattern | Cause |\n|---|---|\n| FLE on HTTP behaviour | FLE requires HTTPS-only viewer requests |\n| Public key expired or rotated without updating profile | Encryption fails; CF returns 502 |\n| Query profile missing from the behaviour | FLE has no profile to apply |\n| Content-Type not in the FLE content-type list | FLE skips; downstream may reject |\n\nFix: HTTPS-only, valid public key, content-type match.\n\n### Step 11: ORIGIN_RESPONSE_TIMEOUT — 504\n\nSymptom: `504` consistently after N seconds. Origin TTFB exceeds CF's\n30-second response timeout.\n\n```bash\ncurl -sv --resolve \u003Corigin>:443:\u003Cip> https:\u002F\u002F\u003Corigin>\u002F\u003Cslow-path> \\\n  -o \u002Fdev\u002Fnull -w '%{time_starttransfer}s %{time_total}s\\n'\n```\n\nIf TTFB consistently exceeds 30s, **ROOT_CAUSE_IDENTIFIED** with\n`LAYER: ORIGIN_RESPONSE_TIMEOUT`. Fix: optimise the origin (DB query,\ncache), or move the long-running operation to async.\n\n### Step 12: ORIGIN_SHIELD_MISCONFIGURATION\n\nSymptom: 502 only when OriginShield enabled; disabling it makes the 502\ndisappear.\n\n```bash\naws cloudfront get-distribution-config --id \u003Cid> --output json | \\\n  jq '.DistributionConfig.Origins.Items[].OriginShield'\n```\n\nOriginShield changes the source IP range (shield POP, not edge POPs).\nOrigin firewalls that whitelisted edge-POP IPs will block shield traffic.\n**ROOT_CAUSE_IDENTIFIED** with `LAYER: ORIGIN_SHIELD_MISCONFIGURATION`.\n\n### Step 13: DISTRIBUTION_NOT_DEPLOYED\n\nSymptom: 502 begins immediately after a config edit; behaviour is\ninconsistent across POPs.\n\n```bash\naws cloudfront get-distribution --id \u003Cid> --output json | \\\n  jq '.Distribution | {Status, LastModifiedTime}'\n```\n\nIf `Status: InProgress`, the new config is still propagating; mixed\nresults are normal. **ROOT_CAUSE_IDENTIFIED** with\n`LAYER: DISTRIBUTION_NOT_DEPLOYED`. Fix: wait for `Deployed`; do not\nroll back unless the new config is genuinely broken.\n\n### Step 14: CACHED_ERROR_RESPONSE — stale error cache\n\nSymptom: Origin recovered (direct probe returns 200), but CloudFront\ncontinues to serve 502. Access log shows\n`x-cache: Error from cloudfront`.\n\n```bash\naws cloudfront get-distribution-config --id \u003Cid> --output json | \\\n  jq '.DistributionConfig.CustomErrorResponses'\n\ncurl -sv -H 'Cache-Control: no-cache' \\\n  https:\u002F\u002F\u003Cdistribution>\u002F\u003Cpath> 2>&1 | grep -E 'HTTP\u002F|x-cache|age:'\n```\n\nIf a no-cache request succeeds but the cached request still returns\n502, a Custom Error Response with non-zero `ErrorCachingMinTTL` is the\ncause. **ROOT_CAUSE_IDENTIFIED** with `LAYER: CACHED_ERROR_RESPONSE`.\nFix: invalidate the error path.\n\n```bash\naws cloudfront create-invalidation --distribution-id \u003Cid> \\\n  --paths '\u002F\u003Cpath>\u002F*' --profile \u003Cp>\n```\n\n### Step 15: Escalate or INSUFFICIENT_DATA\n\nIf none of the above produced a positive root-cause match, OR the\nsymptom indicates an AWS-side incident (regional CloudFront event, S3\noutage), emit INSUFFICIENT_DATA with `LAYER: UNKNOWN` (or escalate via\nINSUFFICIENT_DATA noting the AWS Health event ARN).\n\n## Output format\n\n```text\nTARGET: \u003Cdistribution-id> (domain: \u003Cdistribution-domain-name>)\nVERDICT: ROOT_CAUSE_IDENTIFIED | INSUFFICIENT_DATA\nREASON: \u003C1-2 sentences naming the failed layer and the failing probe>\nLAYER: \u003CORIGIN_CONNECTION_TIMEOUT | ORIGIN_TLS_PROTOCOL_MISMATCH |\n        ORIGIN_TLS_CIPHER_MISMATCH | ORIGIN_RESPONSE_TOO_LARGE |\n        CUSTOM_HEADER_VALIDATION | LAMBDA_AT_EDGE_ERROR |\n        OAC_MISCONFIGURATION | FAILOVER_MISCONFIGURATION |\n        GEO_RESTRICTION_BLOCKING | FIELD_LEVEL_ENCRYPTION_ERROR |\n        ORIGIN_RESPONSE_TIMEOUT | ORIGIN_SHIELD_MISCONFIGURATION |\n        DISTRIBUTION_NOT_DEPLOYED | CACHED_ERROR_RESPONSE | UNKNOWN>\nEVIDENCE:\n  - \u003Cobserved symptom — status code, x-edge-result-type, x-cache>\n  - \u003Cfailing probe — command and its output that confirms the cause>\n  - \u003Cpassing probes — layers ruled out>\nREMEDIATION:\n  1. \u003Cspecific action with CLI command>\n  2. \u003Cverification command after the fix>\nCONFIRM: Before executing any state-changing CLI, emit and await\n  operator approval: \"CONFIRM: About to \u003Caction> on \u003Cdistribution-id>.\n  Proceed? (yes\u002Fno)\"\n```\n\n## Anti-Patterns — NEVER\n\n- NEVER declare ROOT_CAUSE_IDENTIFIED without a failing probe that\n  matches the symptom. A \"process of elimination\" diagnosis erodes\n  operator trust.\n\n- NEVER conflate viewer-to-edge TLS with edge-to-origin TLS. The\n  distribution's ViewerCertificate and OriginSslProtocols are\n  independent. A green viewer-side padlock does NOT mean the origin\n  handshake is healthy.\n\n- NEVER debug an S3 origin's 502 as a \"connection issue.\" S3 is highly\n  available; the cause is almost always OAC\u002Fbucket policy. Probe OAC\n  before connection-layer tools.\n\n- NEVER tail Lambda@Edge logs in the distribution's region. Lambda@Edge\n  function logs are in us-east-1 only. The log group is\n  `\u002Faws\u002Flambda\u002Fus-east-1.\u003Cfunction-name>`.\n\n- NEVER assume a Custom Error Response is harmless. A high TTL on\n  error responses hides recovered origins for minutes. Always check\n  CustomErrorResponses before declaring a CF-side bug.\n\n- NEVER add OriginShield without confirming the origin's firewall\n  accepts traffic from CloudFront's shield POP IPs. OriginShield changes\n  the source IP range.\n\n- NEVER define an OriginGroup without attaching a CacheBehavior to it.\n  Failover does not trigger unless the behaviour's `TargetOriginId` is\n  the group, not the primary origin.\n\n- NEVER treat a 502 during `Status: InProgress` as an origin failure.\n  Mixed POP results during propagation are normal. Wait for `Deployed`.\n\n- NEVER migrate OAI to OAC without updating the bucket policy. The OAC\n  principal (`Service: cloudfront.amazonaws.com` with SourceArn) differs\n  from the OAI canonical user. Leaving the old policy breaks every\n  S3-origin request.\n\n- NEVER enable FLE on an HTTP-allowed behaviour. FLE requires HTTPS-only\n  viewer requests; enabling FLE on a behaviour that allows HTTP produces\n  502s on all HTTP requests.\n\n- NEVER assume the `x-edge-result-type` field is optional. It is the\n  single most disambiguating field. A 502 with `FunctionExecutionError`\n  is a Lambda@Edge problem; a 502 with `Error` is an origin problem.\n\n- NEVER recommend `match-viewer` for OriginProtocolPolicy without\n  flagging the security implication: if any viewer uses HTTP, the origin\n  fetch is also HTTP (cleartext). Prefer `https-only`.\n\n## Pre-flight safety checks\n\nPre-flight safety checks (CONFIRMATION GATE, read-only probes, invalidation billing, Lambda@Edge versioning, bucket-policy blast radius) moved verbatim to [references\u002Fdiagnostic-commands.md](references\u002Fdiagnostic-commands.md).\nLoad them before emitting any remediation CLI.\n\n## Configuration dependency graph\n\nConfiguration dependency graph (viewer -> edge -> shield -> origin -> response, with step mapping) moved verbatim to [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md).\nLoad on demand when mapping a config field to its diagnostic step.\n\n## Expert heuristic\n\nHighest-signal heuristics (origin-side TLS mismatch after https-only; stale error cache after origin recovery) moved verbatim to [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md).\nLoad on demand for the 60-second triage before walking the tree.\n\n## References (load on demand)\n\n- [references\u002Fcloudfront-502-layer-reference.md](references\u002Fcloudfront-502-layer-reference.md) — x-edge-result-type decode, TLS negotiation detail, OAC signing behaviour, Lambda@Edge runtime caps, Custom Error Response TTL guidance\n- [references\u002Fdiagnostic-commands.md](references\u002Fdiagnostic-commands.md) — pre-flight gather-info commands and pre-flight safety checks moved from SKILL.md\n- [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) — philosophy, Step 0 non-obvious behaviours, configuration dependency graph, and expert heuristics moved from SKILL.md\n\n## Domain\n\nAWS CloudOps \u002F CloudFront CDN Edge Networking, Origin Integration,\nLambda@Edge Runtime, and S3 Origin Access Control.\n\n## AWS documentation\n\n- **CloudFront HTTP 502 status code** — https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudFront\u002Flatest\u002FDeveloperGuide\u002Fhttp-502-bad-gateway.html\n- **CloudFront HTTP 504 status code** — https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudFront\u002Flatest\u002FDeveloperGuide\u002Fhttp-504-gateway-timeout.html\n- **Origin access control** — https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudFront\u002Flatest\u002FDeveloperGuide\u002Fprivate-content-restricting-access-to-s3.html\n- **Lambda@Edge** — https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudFront\u002Flatest\u002FDeveloperGuide\u002Flambda-at-the-edge.html\n- **Origin Shield** — https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudFront\u002Flatest\u002FDeveloperGuide\u002Forigin-shield.html\n- **Custom Error Responses** — https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudFront\u002Flatest\u002FDeveloperGuide\u002FGeneratingCustomErrors.html\n- **CloudFront access logs** — https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudFront\u002Flatest\u002FDeveloperGuide\u002FAccessLogs.html\n","# CloudFront 502 Troubleshooter\n\n## Quick start\n\n- **Symptom -> layer map (first plausible match drives the first probe):**\n  a fresh `502` after a config deploy -> LAMBDA_AT_EDGE_ERROR \u002F\n  CUSTOM_HEADER_VALIDATION \u002F ORIGIN_TLS_PROTOCOL_MISMATCH; `502` only\n  from one edge POP -> ORIGIN_SHIELD_MISCONFIGURATION; `504` after N\n  seconds -> ORIGIN_RESPONSE_TIMEOUT or ORIGIN_CONNECTION_TIMEOUT;\n  `502` from S3 origin only -> OAC_MISCONFIGURATION; `502` from one\n  country -> GEO_RESTRICTION_BLOCKING; intermittent 502 lingering after\n  origin recovery -> CACHED_ERROR_RESPONSE.\n- **Read `x-cache` and `x-edge-result-type` before guessing.**\n  `x-cache: Error from cloudfront` = edge produced the 502 (Lambda@Edge,\n  FLE, geo, error cache); `x-cache: Error from origin` = origin\n  returned 5xx to CF. The tree forks at this single field.\n- **Reproduce from outside the cache first.** A `curl -H\n  'Cache-Control: no-cache'` forces a fresh origin fetch. If the 502\n  disappears, the cause is CACHED_ERROR_RESPONSE, not the live origin.\n- **Probe the origin directly with the exact viewer request.** `curl\n  --resolve \u003Corigin>:443:\u003Cip>` with the same Host, protocol, path. A\n  502 here proves origin-side fault; a 200 here proves the failure is\n  between CF and the origin.\n- **A new 502 that appears immediately after a distribution deploy is\n  almost always the deploy, not the origin.** Check `Status: InProgress`\n  first; mixed POP results during propagation are expected.\n\n## Mindset\n\nA CloudFront 502 is a transport- or transaction-layer failure between\nthe edge POP and the origin (or between the viewer and the edge when\nLambda@Edge fails). The body of the 502 page is generic; the\nload-bearing evidence lives in `x-edge-result-type`, `x-cache`, and\n`x-amz-cf-pop` of the access log and in the origin's own response\nwhen probed directly. Senior CDN engineers start with the access log\nrow for a failing request, not the distribution config. The config\nnarrows the search; the log row identifies the layer.\n\n## Philosophy\n\nSenior-engineer philosophy (edge vs origin 502, TLS mismatch, silent OAC failures, error-cache TTL) moved verbatim to [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md).\nLoad on demand when a 502 looks like an origin fault but the evidence points elsewhere.\n\n## Pre-flight: distribution state and gather-info gate\n\nPre-flight gather-info command listing (config, status, logs, viewer curl, origin probe) moved verbatim to [references\u002Fdiagnostic-commands.md](references\u002Fdiagnostic-commands.md).\nRun these read-only probes before any symptom-specific branch of the tree.\n\n| `Status` | Effect on diagnosis |\n|---|---|\n| `Deployed` | Proceed with symptom-driven diagnosis. |\n| `InProgress` | Config update is propagating (5-15 min). Mixed POP behaviour is expected. Wait before drawing conclusions. |\n| `InProgress` > 30 minutes | Stuck deploy; open a Support case. |\n\nThe load-bearing access-log fields for 502 diagnosis: `x-edge-result-type`\n(`Error` vs `FunctionExecutionError` vs `LimitExceeded`),\n`x-edge-response-result-type`, `x-cache` (`Error from cloudfront` vs\n`Error from origin`), `ssl-protocol` \u002F `ssl-cipher` (viewer-side only),\n`fle-status`, `time-taken`.\n\nIf the input is malformed (missing DistributionId, no symptom\ndescription, no curl reproduction or access-log row), emit:\n\n```text\nTARGET: \u003Cdistribution-id or unknown>\nVERDICT: INSUFFICIENT_DATA\nREASON: Input is missing required context — at minimum a symptom\n  description (HTTP 502\u002F504 status) and the DistributionId. Access-log\n  excerpts or a curl reproduction are required for high-confidence\n  layer identification.\nLAYER: UNKNOWN\nEVIDENCE:\n  - Missing: \u003Clist specific missing fields>\nREMEDIATION: Re-prompt the operator for: (1) DistributionId and failing\n  path; (2) curl reproduction with response headers; (3) at least one\n  access-log row showing the 502\u002F504; (4) recent deployment timestamps.\n```\n\n## Quick reference — symptom triage table\n\n| Symptom \u002F log signal | Most likely layer | First probe |\n|---|---|---|\n| `x-cache: Error from origin` + origin unreachable | ORIGIN_CONNECTION_TIMEOUT | `elbv2 describe-target-health` (ALB) or `s3api head-object` (S3) |\n| `x-cache: Error from origin` + handshake errors | ORIGIN_TLS_PROTOCOL_MISMATCH \u002F ORIGIN_TLS_CIPHER_MISMATCH | `openssl s_client -connect origin:443` from edge-like client |\n| 502 only on responses > 10 MB | ORIGIN_RESPONSE_TOO_LARGE | Origin `Content-Length` vs CF payload cap |\n| 502 begins after adding `OriginCustomHeader` | CUSTOM_HEADER_VALIDATION | Compare header value at origin vs config |\n| `x-edge-result-type: FunctionExecutionError` | LAMBDA_AT_EDGE_ERROR | `logs filter-log-events` on `\u002Faws\u002Flambda\u002Fus-east-1.\u003Cfn>` in us-east-1 |\n| 502 only on S3 origin, ALB origin fine | OAC_MISCONFIGURATION | `s3api get-bucket-policy` + verify `cloudfront:GetResource` principal |\n| 502 when primary fails; secondary never reached | FAILOVER_MISCONFIGURATION | `get-distribution-config` OriginGroups + behaviour `TargetOriginId` |\n| 502 only from one country; `x-edge-result-type: LimitExceeded` | GEO_RESTRICTION_BLOCKING | `get-distribution-config` Restrictions.GeoRestriction |\n| 502 with field-level encryption recently enabled | FIELD_LEVEL_ENCRYPTION_ERROR | Verify public key, query profile, content-type |\n| `504` consistently after N seconds of TTFB | ORIGIN_RESPONSE_TIMEOUT | Origin app logs; curl TTFB measurement |\n| 502 only when OriginShield enabled | ORIGIN_SHIELD_MISCONFIGURATION | `get-distribution-config` OriginShield config |\n| `Status: InProgress`; mixed results across POPs | DISTRIBUTION_NOT_DEPLOYED | `get-distribution` Status, LastModifiedTime |\n| Origin recovered but 502 persists for minutes | CACHED_ERROR_RESPONSE | `Cache-Control` \u002F `age` header; Custom Error Response TTL |\n\n## Process — Diagnostic decision tree\n\nSymptom-driven. Each layer ends with a positive root-cause confirmation\n(a failing probe that matches the symptom) or a pass that moves to the\nnext layer. **Never emit ROOT_CAUSE_IDENTIFIED without a failing probe\nthat matches the symptom.**\n\n### Step 0: Non-obvious behaviours that change diagnosis\n\nStep 0 non-obvious behaviours (log region, Origin Shield IP ranges, failover wiring, OAC principal, error cache, FLE, InProgress) moved verbatim to [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md).\nLoad on demand when the obvious layer does not match the symptom.\n\n### Step 1: Symptom entry — pick the diagnostic branch\n\n| Symptom | Branch |\n|---|---|\n| `x-edge-result-type: FunctionExecutionError` | Step 4 — Lambda@Edge |\n| `x-edge-result-type: LimitExceeded` | Step 9 (geo) or WAF (out of scope) |\n| `x-cache: Error from cloudfront` + fresh deploy | Step 5 (custom header) or Step 7 (OAC) |\n| `x-cache: Error from origin` + ALB\u002FNLB origin | Step 2 (connection) |\n| `x-cache: Error from origin` + S3 origin | Step 7 (OAC) |\n| `x-cache: Error from origin` + TLS handshake errors | Step 3 (TLS) |\n| `504` consistently after N seconds | Step 11 (response timeout) |\n| 502 only from specific country | Step 9 (geo restriction) |\n| 502 lingers after origin recovered | Step 14 (cached error) |\n| 502 with FLE recently enabled | Step 10 (FLE) |\n| None of the above | Step 15 (escalate) |\n\n### Step 2: ORIGIN_CONNECTION_TIMEOUT — origin unreachable\n\nSymptom: `x-cache: Error from origin`, origin's own access log shows no\nmatching request (connection never established).\n\n```bash\naws cloudfront get-distribution-config --id \u003Cid> --output json | \\\n  jq '.DistributionConfig.Origins.Items[].DomainName'\n\naws elbv2 describe-target-health --target-group-arn \u003Carn> --output json\n```\n\nIf `target-health` returns no healthy targets, **ROOT_CAUSE_IDENTIFIED**\nwith `LAYER: ORIGIN_CONNECTION_TIMEOUT`. For S3 origins, a 502 usually\nmeans OAC (Step 7), not connection failure — S3 is highly available.\n\n### Step 3: ORIGIN_TLS_PROTOCOL_MISMATCH \u002F ORIGIN_TLS_CIPHER_MISMATCH\n\nSymptom: `x-cache: Error from origin`, origin's access log shows zero\nmatching requests (handshake never completed). Often after a config\nchange to `OriginProtocolPolicy: https-only`.\n\n```bash\naws cloudfront get-distribution-config --id \u003Cid> --output json | \\\n  jq '.DistributionConfig.Origins.Items[] |\n      {DomainName, OriginProtocolPolicy, OriginSslProtocols}'\n\nopenssl s_client -connect \u003Corigin>:443 -servername \u003Corigin> -tls1_2 2>&1 | head -40\nopenssl s_client -connect \u003Corigin>:443 -servername \u003Corigin> -tls1_3 2>&1 | head -40\n```\n\n| Probe result | Layer |\n|---|---|\n| `OriginProtocolPolicy: https-only`, origin listens HTTP only | ORIGIN_TLS_PROTOCOL_MISMATCH |\n| `OriginSslProtocols: [TLSv1.2]`, origin supports TLSv1.0 \u002F TLSv1.1 only | ORIGIN_TLS_PROTOCOL_MISMATCH |\n| Cipher suite negotiation fails (`no shared cipher`) | ORIGIN_TLS_CIPHER_MISMATCH |\n| Origin certificate expired or untrusted chain | ORIGIN_TLS_PROTOCOL_MISMATCH (cert validation) |\n\nFix: align `OriginProtocolPolicy` with what the origin serves, and\nensure `OriginSslProtocols` includes at least one protocol the origin\nsupports.\n\n### Step 4: LAMBDA_AT_EDGE_ERROR — function runtime failure\n\nSymptom: `x-edge-result-type: FunctionExecutionError`. The function\n(viewer-request \u002F origin-request \u002F origin-response \u002F viewer-response)\nthrew an unhandled exception or exceeded its timeout cap.\n\n```bash\naws cloudfront get-distribution-config --id \u003Cid> --output json | \\\n  jq '.DistributionConfig.CacheBehaviors.Items[].LambdaFunctionAssociations'\n\n# Logs in us-east-1 ONLY for Lambda@Edge\naws logs filter-log-events \\\n  --log-group-name \u002Faws\u002Flambda\u002Fus-east-1.\u003Cfunction-name> \\\n  --start-time $(date -d '-30 minutes' +%s)000 \\\n  --filter-pattern '\"ERROR\" OR \"Task timed out\" OR \"Unhandled\"' \\\n  --region us-east-1 --output json\n```\n\n| Pattern | Cause |\n|---|---|\n| Function throws on specific request shape | Bad header parsing, undefined field, large payload |\n| `Task timed out` | Function exceeds 5s (viewer) or 30s (origin) cap |\n| Function size > 1 MB (viewer) \u002F 50 MB (origin) | Exceeds Lambda@Edge size cap; deploy fails |\n| 502 only on \u002Fspecific-path | Function logic branches on URI; one branch throws |\n| Function references `process.env.X` | Lambda@Edge does NOT support env vars; always undefined |\n\nFix: fix the function code, redeploy, and publish a new version ARN.\n\n### Step 5: CUSTOM_HEADER_VALIDATION — origin rejects custom header\n\nSymptom: `x-cache: Error from origin`, recent edit to\n`OriginCustomHeader`. Origin's WAF \u002F auth layer returns 4xx\u002F5xx because\nof header value mismatch.\n\n```bash\naws cloudfront get-distribution-config --id \u003Cid> --output json | \\\n  jq '.DistributionConfig.Origins.Items[].CustomHeaders'\n```\n\nIf the origin expects a different value or header name,\n**ROOT_CAUSE_IDENTIFIED** with `LAYER: CUSTOM_HEADER_VALIDATION`. Align\nthe value in the distribution config OR update the origin's auth module.\n\n### Step 6: ORIGIN_RESPONSE_TOO_LARGE — payload cap exceeded\n\nSymptom: 502 only on large responses.\n\n```bash\ncurl -sv --resolve \u003Corigin>:443:\u003Cip> https:\u002F\u002F\u003Corigin>\u002F\u003Clarge-path> \\\n  -o \u002Fdev\u002Fnull -w '%{size_download} %{http_code}\\n'\n```\n\nIf `size_download` consistently hits a cap and CF truncates with 502,\n**ROOT_CAUSE_IDENTIFIED** with `LAYER: ORIGIN_RESPONSE_TOO_LARGE`. Fix:\npaginate, use range requests, or move to S3 with byte-range serving.\n\n### Step 7: OAC_MISCONFIGURATION — S3 origin access control\n\nSymptom: `x-cache: Error from origin` for S3 origin; bucket policy\nrecently edited or migrated OAI -> OAC.\n\n```bash\naws cloudfront get-distribution-config --id \u003Cid> --output json | \\\n  jq '.DistributionConfig.Origins.Items[] |\n      {DomainName, S3OriginConfig, OriginAccessControlId}'\n\naws cloudfront list-origin-access-controls --output json\naws s3api get-bucket-policy --bucket \u003Cbucket> --output json\n```\n\n| Pattern | Cause |\n|---|---|\n| Bucket policy grants legacy OAI (`CanonicalUser`), CF uses OAC | Principal mismatch; S3 returns 403 to CF |\n| OAC `SigningBehavior: always`, bucket policy lacks `cloudfront:GetResource` | S3 rejects the signed request |\n| Bucket policy restricts by `aws:SourceIp`; CF IPs not allowed | S3 denies |\n| Migrated OAI -> OAC, bucket policy not updated | Policy still references the OAI principal |\n\nFix: update the bucket policy to grant the OAC principal\n(`Service: cloudfront.amazonaws.com`) with `AWS:SourceArn` equal to the\ndistribution ARN.\n\n### Step 8: FAILOVER_MISCONFIGURATION — multi-origin routing\n\nSymptom: 502 when primary fails; secondary never receives traffic.\n\n```bash\naws cloudfront get-distribution-config --id \u003Cid> --output json | \\\n  jq '.DistributionConfig.OriginGroups.Items[] |\n      {Id, FailoverCriteria, Members}'\n# Verify the behaviour points at the group, not the single origin\njq '.DistributionConfig.CacheBehaviors.Items[].TargetOriginId'\n```\n\n| Pattern | Cause |\n|---|---|\n| Behaviour `TargetOriginId` is the primary origin, not the group | Failover never triggers |\n| `FailoverCriteria.StatusCodes` excludes the 5xx primary returns | Group considers primary healthy |\n| Secondary origin unreachable | Failover triggers but secondary also fails |\n\n### Step 9: GEO_RESTRICTION_BLOCKING — geographic block\n\nSymptom: 502 \u002F 403 only from one country. `x-edge-result-type: LimitExceeded`.\n\n```bash\naws cloudfront get-distribution-config --id \u003Cid> --output json | \\\n  jq '.DistributionConfig.Restrictions.GeoRestriction'\n```\n\nIf the failing viewer's country is on the wrong side of a `whitelist` or\n`blacklist`, **ROOT_CAUSE_IDENTIFIED** with\n`LAYER: GEO_RESTRICTION_BLOCKING`. Note: CF returns 403 for geo blocks,\nbut a Custom Error Response can map this to 502 if misconfigured.\n\n### Step 10: FIELD_LEVEL_ENCRYPTION_ERROR — FLE failure\n\nSymptom: 502 with FLE recently enabled. Access log shows\n`fle-status: error` or empty `fle-encrypted-fields`.\n\n| Pattern | Cause |\n|---|---|\n| FLE on HTTP behaviour | FLE requires HTTPS-only viewer requests |\n| Public key expired or rotated without updating profile | Encryption fails; CF returns 502 |\n| Query profile missing from the behaviour | FLE has no profile to apply |\n| Content-Type not in the FLE content-type list | FLE skips; downstream may reject |\n\nFix: HTTPS-only, valid public key, content-type match.\n\n### Step 11: ORIGIN_RESPONSE_TIMEOUT — 504\n\nSymptom: `504` consistently after N seconds. Origin TTFB exceeds CF's\n30-second response timeout.\n\n```bash\ncurl -sv --resolve \u003Corigin>:443:\u003Cip> https:\u002F\u002F\u003Corigin>\u002F\u003Cslow-path> \\\n  -o \u002Fdev\u002Fnull -w '%{time_starttransfer}s %{time_total}s\\n'\n```\n\nIf TTFB consistently exceeds 30s, **ROOT_CAUSE_IDENTIFIED** with\n`LAYER: ORIGIN_RESPONSE_TIMEOUT`. Fix: optimise the origin (DB query,\ncache), or move the long-running operation to async.\n\n### Step 12: ORIGIN_SHIELD_MISCONFIGURATION\n\nSymptom: 502 only when OriginShield enabled; disabling it makes the 502\ndisappear.\n\n```bash\naws cloudfront get-distribution-config --id \u003Cid> --output json | \\\n  jq '.DistributionConfig.Origins.Items[].OriginShield'\n```\n\nOriginShield changes the source IP range (shield POP, not edge POPs).\nOrigin firewalls that whitelisted edge-POP IPs will block shield traffic.\n**ROOT_CAUSE_IDENTIFIED** with `LAYER: ORIGIN_SHIELD_MISCONFIGURATION`.\n\n### Step 13: DISTRIBUTION_NOT_DEPLOYED\n\nSymptom: 502 begins immediately after a config edit; behaviour is\ninconsistent across POPs.\n\n```bash\naws cloudfront get-distribution --id \u003Cid> --output json | \\\n  jq '.Distribution | {Status, LastModifiedTime}'\n```\n\nIf `Status: InProgress`, the new config is still propagating; mixed\nresults are normal. **ROOT_CAUSE_IDENTIFIED** with\n`LAYER: DISTRIBUTION_NOT_DEPLOYED`. Fix: wait for `Deployed`; do not\nroll back unless the new config is genuinely broken.\n\n### Step 14: CACHED_ERROR_RESPONSE — stale error cache\n\nSymptom: Origin recovered (direct probe returns 200), but CloudFront\ncontinues to serve 502. Access log shows\n`x-cache: Error from cloudfront`.\n\n```bash\naws cloudfront get-distribution-config --id \u003Cid> --output json | \\\n  jq '.DistributionConfig.CustomErrorResponses'\n\ncurl -sv -H 'Cache-Control: no-cache' \\\n  https:\u002F\u002F\u003Cdistribution>\u002F\u003Cpath> 2>&1 | grep -E 'HTTP\u002F|x-cache|age:'\n```\n\nIf a no-cache request succeeds but the cached request still returns\n502, a Custom Error Response with non-zero `ErrorCachingMinTTL` is the\ncause. **ROOT_CAUSE_IDENTIFIED** with `LAYER: CACHED_ERROR_RESPONSE`.\nFix: invalidate the error path.\n\n```bash\naws cloudfront create-invalidation --distribution-id \u003Cid> \\\n  --paths '\u002F\u003Cpath>\u002F*' --profile \u003Cp>\n```\n\n### Step 15: Escalate or INSUFFICIENT_DATA\n\nIf none of the above produced a positive root-cause match, OR the\nsymptom indicates an AWS-side incident (regional CloudFront event, S3\noutage), emit INSUFFICIENT_DATA with `LAYER: UNKNOWN` (or escalate via\nINSUFFICIENT_DATA noting the AWS Health event ARN).\n\n## Output format\n\n```text\nTARGET: \u003Cdistribution-id> (domain: \u003Cdistribution-domain-name>)\nVERDICT: ROOT_CAUSE_IDENTIFIED | INSUFFICIENT_DATA\nREASON: \u003C1-2 sentences naming the failed layer and the failing probe>\nLAYER: \u003CORIGIN_CONNECTION_TIMEOUT | ORIGIN_TLS_PROTOCOL_MISMATCH |\n        ORIGIN_TLS_CIPHER_MISMATCH | ORIGIN_RESPONSE_TOO_LARGE |\n        CUSTOM_HEADER_VALIDATION | LAMBDA_AT_EDGE_ERROR |\n        OAC_MISCONFIGURATION | FAILOVER_MISCONFIGURATION |\n        GEO_RESTRICTION_BLOCKING | FIELD_LEVEL_ENCRYPTION_ERROR |\n        ORIGIN_RESPONSE_TIMEOUT | ORIGIN_SHIELD_MISCONFIGURATION |\n        DISTRIBUTION_NOT_DEPLOYED | CACHED_ERROR_RESPONSE | UNKNOWN>\nEVIDENCE:\n  - \u003Cobserved symptom — status code, x-edge-result-type, x-cache>\n  - \u003Cfailing probe — command and its output that confirms the cause>\n  - \u003Cpassing probes — layers ruled out>\nREMEDIATION:\n  1. \u003Cspecific action with CLI command>\n  2. \u003Cverification command after the fix>\nCONFIRM: Before executing any state-changing CLI, emit and await\n  operator approval: \"CONFIRM: About to \u003Caction> on \u003Cdistribution-id>.\n  Proceed? (yes\u002Fno)\"\n```\n\n## Anti-Patterns — NEVER\n\n- NEVER declare ROOT_CAUSE_IDENTIFIED without a failing probe that\n  matches the symptom. A \"process of elimination\" diagnosis erodes\n  operator trust.\n\n- NEVER conflate viewer-to-edge TLS with edge-to-origin TLS. The\n  distribution's ViewerCertificate and OriginSslProtocols are\n  independent. A green viewer-side padlock does NOT mean the origin\n  handshake is healthy.\n\n- NEVER debug an S3 origin's 502 as a \"connection issue.\" S3 is highly\n  available; the cause is almost always OAC\u002Fbucket policy. Probe OAC\n  before connection-layer tools.\n\n- NEVER tail Lambda@Edge logs in the distribution's region. Lambda@Edge\n  function logs are in us-east-1 only. The log group is\n  `\u002Faws\u002Flambda\u002Fus-east-1.\u003Cfunction-name>`.\n\n- NEVER assume a Custom Error Response is harmless. A high TTL on\n  error responses hides recovered origins for minutes. Always check\n  CustomErrorResponses before declaring a CF-side bug.\n\n- NEVER add OriginShield without confirming the origin's firewall\n  accepts traffic from CloudFront's shield POP IPs. OriginShield changes\n  the source IP range.\n\n- NEVER define an OriginGroup without attaching a CacheBehavior to it.\n  Failover does not trigger unless the behaviour's `TargetOriginId` is\n  the group, not the primary origin.\n\n- NEVER treat a 502 during `Status: InProgress` as an origin failure.\n  Mixed POP results during propagation are normal. Wait for `Deployed`.\n\n- NEVER migrate OAI to OAC without updating the bucket policy. The OAC\n  principal (`Service: cloudfront.amazonaws.com` with SourceArn) differs\n  from the OAI canonical user. Leaving the old policy breaks every\n  S3-origin request.\n\n- NEVER enable FLE on an HTTP-allowed behaviour. FLE requires HTTPS-only\n  viewer requests; enabling FLE on a behaviour that allows HTTP produces\n  502s on all HTTP requests.\n\n- NEVER assume the `x-edge-result-type` field is optional. It is the\n  single most disambiguating field. A 502 with `FunctionExecutionError`\n  is a Lambda@Edge problem; a 502 with `Error` is an origin problem.\n\n- NEVER recommend `match-viewer` for OriginProtocolPolicy without\n  flagging the security implication: if any viewer uses HTTP, the origin\n  fetch is also HTTP (cleartext). Prefer `https-only`.\n\n## Pre-flight safety checks\n\nPre-flight safety checks (CONFIRMATION GATE, read-only probes, invalidation billing, Lambda@Edge versioning, bucket-policy blast radius) moved verbatim to [references\u002Fdiagnostic-commands.md](references\u002Fdiagnostic-commands.md).\nLoad them before emitting any remediation CLI.\n\n## Configuration dependency graph\n\nConfiguration dependency graph (viewer -> edge -> shield -> origin -> response, with step mapping) moved verbatim to [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md).\nLoad on demand when mapping a config field to its diagnostic step.\n\n## Expert heuristic\n\nHighest-signal heuristics (origin-side TLS mismatch after https-only; stale error cache after origin recovery) moved verbatim to [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md).\nLoad on demand for the 60-second triage before walking the tree.\n\n## References (load on demand)\n\n- [references\u002Fcloudfront-502-layer-reference.md](references\u002Fcloudfront-502-layer-reference.md) — x-edge-result-type decode, TLS negotiation detail, OAC signing behaviour, Lambda@Edge runtime caps, Custom Error Response TTL guidance\n- [references\u002Fdiagnostic-commands.md](references\u002Fdiagnostic-commands.md) — pre-flight gather-info commands and pre-flight safety checks moved from SKILL.md\n- [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) — philosophy, Step 0 non-obvious behaviours, configuration dependency graph, and expert heuristics moved from SKILL.md\n\n## Domain\n\nAWS CloudOps \u002F CloudFront CDN Edge Networking, Origin Integration,\nLambda@Edge Runtime, and S3 Origin Access Control.\n\n## AWS documentation\n\n- **CloudFront HTTP 502 status code** — https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudFront\u002Flatest\u002FDeveloperGuide\u002Fhttp-502-bad-gateway.html\n- **CloudFront HTTP 504 status code** — https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudFront\u002Flatest\u002FDeveloperGuide\u002Fhttp-504-gateway-timeout.html\n- **Origin access control** — https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudFront\u002Flatest\u002FDeveloperGuide\u002Fprivate-content-restricting-access-to-s3.html\n- **Lambda@Edge** — https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudFront\u002Flatest\u002FDeveloperGuide\u002Flambda-at-the-edge.html\n- **Origin Shield** — https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudFront\u002Flatest\u002FDeveloperGuide\u002Forigin-shield.html\n- **Custom Error Responses** — https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudFront\u002Flatest\u002FDeveloperGuide\u002FGeneratingCustomErrors.html\n- **CloudFront access logs** — https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudFront\u002Flatest\u002FDeveloperGuide\u002FAccessLogs.html\n",{"name":5,"license":15,"metadata":24,"description":7,"compatibility":44},{"tags":25,"phase":26,"author":27,"domain":28,"family":29,"version":30,"keywords":31,"task_type":32,"complexity":33,"entry_point":34,"skill_class":35,"when_to_use":36,"requires_llm":37,"verdict_shape":38,"when_not_to_use":39,"lifecycle_status":40,"invocation_schema":41,"supports_pipeline":37,"invocation_example":42,"activation_triggers":43},"cloudfront, networking, cdn, troubleshooting, 502, tls, lambda-at-edge, oac","2","Jacky Chan — AWS Community Builder","aws-cloudops","Networking","0.1.0","CloudFront, 502, 504, Bad Gateway, Gateway Timeout, origin connection timeout, TLS negotiation failure, SSL protocol mismatch, cipher suite mismatch, Lambda@Edge, Origin Access Control, OAC, multi-origin failover, geographic restriction, field-level encryption, origin shield, cached error response, troubleshoot CloudFront","troubleshoot","high","false","capability","Diagnosing a CloudFront distribution returning 502 Bad Gateway or 504 Gateway Timeout — including origin connection failures, TLS handshake errors, Lambda@Edge runtime exceptions, S3 OAC misconfiguration, failover routing, geographic blocks, field-level encryption failures, origin-shield errors, deployment-state artefacts, or stale error-cache entries hiding a now-recovered origin.","true","ROOT_CAUSE_IDENTIFIED | INSUFFICIENT_DATA","Cache hit ratio \u002F stale content without 502\u002F504 (use cloudfront-cache-troubleshooter), cost analysis (use cloudfront-cost-optimizer), distribution creation (use cloudfront-distribution-deployer), or WAF 403 blocks (use wafv2-web-acl-deployer). This skill is scoped to 502\u002F504-class origin and edge failures.","active","Input: either (a) a symptom description (502\u002F504 status, the x-edge-result-type and x-cache values from access logs, viewer error message) optionally paired with the distribution configuration and curl reproduction, OR (b) a DistributionId plus viewer context for live-account diagnosis. Output: a deterministic TARGET \u002F VERDICT \u002F REASON \u002F LAYER \u002F EVIDENCE \u002F REMEDIATION block where VERDICT ∈ {ROOT_CAUSE_IDENTIFIED, INSUFFICIENT_DATA} and LAYER ∈ {ORIGIN_CONNECTION_TIMEOUT, ORIGIN_TLS_PROTOCOL_MISMATCH, ORIGIN_TLS_CIPHER_MISMATCH, ORIGIN_RESPONSE_TOO_LARGE, CUSTOM_HEADER_VALIDATION, LAMBDA_AT_EDGE_ERROR, OAC_MISCONFIGURATION, FAILOVER_MISCONFIGURATION, GEO_RESTRICTION_BLOCKING, FIELD_LEVEL_ENCRYPTION_ERROR, ORIGIN_RESPONSE_TIMEOUT, ORIGIN_SHIELD_MISCONFIGURATION, DISTRIBUTION_NOT_DEPLOYED, CACHED_ERROR_RESPONSE, UNKNOWN}.","# Minimal valid input (offline symptom classification):\nSymptom: \"CloudFront distribution d111111abcdef8.cloudfront.net\nreturns HTTP 502 to all viewers on \u002Fapi\u002F* since 14:10 UTC.\nOrigin is an ALB in us-east-1.\"\nDistributionId: E1Q2W3R4Y5Z6A7\nDomainName: d111111abcdef8.cloudfront.net\nOrigin: api.alb.example.com (ALB, HTTPS-only)\nOriginProtocolPolicy: https-only\nx-edge-result-type from logs: Error\nx-cache from logs: Error from origin\nLast deployment: 1 hour ago (added OriginProtocolPolicy: https-only)\n","CloudFront 502, CloudFront 504, CloudFront Bad Gateway, CloudFront origin connection failed, CloudFront TLS handshake failure, CloudFront Lambda@Edge error, CloudFront OAC 502, CloudFront failover 502, CloudFront geographic block, CloudFront origin shield 502, CloudFront cached 502, troubleshoot CloudFront 502","Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). Offline diagnosis works from pasted CloudFront access-log excerpts, response headers, and distribution config JSON. Live-account diagnosis uses aws cloudfront get-distribution-config \u002F get-distribution \u002F list-origin-access-controls, aws logs filter-log-events on the us-east-1 CloudFront and Lambda@Edge log groups, aws s3api get-bucket-policy \u002F head-object, aws elbv2 describe-load-balancers \u002F...","main","eeace51bd5dd1db2030729d83eeab988861553aa","skills\u002Fcloudfront-502-troubleshooter",0,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills","https:\u002F\u002Fgithub.com\u002Fjhkchan","CTO & Co-Founder @Beever-AI  & @votee. CAISP. AWS Community Builder. Organizer@GDGCloudHK. MongoDB Champion. Technopreneur + Infornographer.","2026-09-24 08:54:10",{"source":8,"skillName":5,"commands":54,"prompt":64,"zipAvailable":65},[55,58,61],{"tool":56,"command":57},"npx","npx skills add jhkchan\u002Faws-agent-skills --skill cloudfront-502-troubleshooter",{"tool":59,"command":60},"bunx","bunx skills add jhkchan\u002Faws-agent-skills --skill cloudfront-502-troubleshooter",{"tool":62,"command":63},"pnpm","pnpm dlx skills add jhkchan\u002Faws-agent-skills --skill cloudfront-502-troubleshooter","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002FSKILL.md",true,[67,73,77,81,85,89,93,97,101,105,109,113,117,121,125,129,133,137],{"path":68,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":72},"eval\u002Ftest-cases.yaml","REFERENCE","参考文档",12799,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002Feval\u002Ftest-cases.yaml",{"path":74,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":75,"sourceHtmlUrl":76},"evals\u002Fbaselines\u002Fcached-error-response-stale-502-after-recovery.md",552,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002Fevals\u002Fbaselines\u002Fcached-error-response-stale-502-after-recovery.md",{"path":78,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":79,"sourceHtmlUrl":80},"evals\u002Fbaselines\u002Ffailover-behaviour-points-at-primary-not-group.md",525,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002Fevals\u002Fbaselines\u002Ffailover-behaviour-points-at-primary-not-group.md",{"path":82,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":83,"sourceHtmlUrl":84},"evals\u002Fbaselines\u002Flambda-at-edge-viewer-request-runtime-error.md",541,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002Fevals\u002Fbaselines\u002Flambda-at-edge-viewer-request-runtime-error.md",{"path":86,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":87,"sourceHtmlUrl":88},"evals\u002Fbaselines\u002Foac-misconfiguration-s3-bucket-policy-stale.md",590,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002Fevals\u002Fbaselines\u002Foac-misconfiguration-s3-bucket-policy-stale.md",{"path":90,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":91,"sourceHtmlUrl":92},"evals\u002Fbaselines\u002Forigin-tls-protocol-mismatch-https-only.md",566,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002Fevals\u002Fbaselines\u002Forigin-tls-protocol-mismatch-https-only.md",{"path":94,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":95,"sourceHtmlUrl":96},"evals\u002Feval_config.yaml",2281,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002Fevals\u002Feval_config.yaml",{"path":98,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":99,"sourceHtmlUrl":100},"evals\u002Fevals.json",5383,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002Fevals\u002Fevals.json",{"path":102,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":103,"sourceHtmlUrl":104},"evals\u002Fprompts\u002Fcached-error-response-stale-502-after-recovery.md",1843,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002Fevals\u002Fprompts\u002Fcached-error-response-stale-502-after-recovery.md",{"path":106,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":107,"sourceHtmlUrl":108},"evals\u002Fprompts\u002Ffailover-behaviour-points-at-primary-not-group.md",1749,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002Fevals\u002Fprompts\u002Ffailover-behaviour-points-at-primary-not-group.md",{"path":110,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":111,"sourceHtmlUrl":112},"evals\u002Fprompts\u002Flambda-at-edge-viewer-request-runtime-error.md",1735,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002Fevals\u002Fprompts\u002Flambda-at-edge-viewer-request-runtime-error.md",{"path":114,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":115,"sourceHtmlUrl":116},"evals\u002Fprompts\u002Foac-misconfiguration-s3-bucket-policy-stale.md",2058,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002Fevals\u002Fprompts\u002Foac-misconfiguration-s3-bucket-policy-stale.md",{"path":118,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":119,"sourceHtmlUrl":120},"evals\u002Fprompts\u002Forigin-tls-protocol-mismatch-https-only.md",1428,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002Fevals\u002Fprompts\u002Forigin-tls-protocol-mismatch-https-only.md",{"path":122,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":123,"sourceHtmlUrl":124},"examples\u002FREADME.md",5753,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002Fexamples\u002FREADME.md",{"path":126,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":127,"sourceHtmlUrl":128},"references\u002Fadvanced-patterns.md",5759,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002Freferences\u002Fadvanced-patterns.md",{"path":130,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":131,"sourceHtmlUrl":132},"references\u002Fcloudfront-502-layer-reference.md",8248,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002Freferences\u002Fcloudfront-502-layer-reference.md",{"path":134,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":135,"sourceHtmlUrl":136},"references\u002Fdiagnostic-commands.md",2293,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002Freferences\u002Fdiagnostic-commands.md",{"path":138,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":139,"sourceHtmlUrl":140},"skill.usf.yaml",4545,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcloudfront-502-troubleshooter\u002Fskill.usf.yaml",[142,149,156,163,170,177],{"skillNo":143,"name":144,"nameZh":6,"description":145,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":146,"categories":147,"keywords":148,"publishedAt":19},"01M7ADVD60X4PCAPKSE58P9NDC","xray-tracing-deployer","Deploys AWS X-Ray distributed tracing with production-grade configuration: X-Ray daemon deployment (EC2 systemd, ECS sidecar, EKS DaemonSet, Lambda built-in), SDK instrumentation (Java, Python, Node.js, Go, .NET) with annotations and metadata, sampling rules (default reservoir + rate vs custom rules with URL \u002F method \u002F service-name predicates), service map generation, trace query and retrieval, groups and insights, CloudWatch ServiceLens integration, IAM permissions (PutTraceSegments, GetSamplingRules), and latest features (Lambda Powertools tracing, OpenTelemetry \u002F ADOT Collector support, W3C trace context). Emits a READY_TO_DEPLOY checklist with every configuration item verified. Use when enabling X-Ray on a new application, adding tracing to ECS \u002F EKS \u002F Lambda, validating a sampling configuration, or generating daemon deployment CLI and IaC templates. Triggers: X-Ray, distributed tracing, X-Ray daemon, sampling rules, service map, X-Ray SDK, OpenTelemetry, ADOT, Lambda Powertools, CloudWatch ServiceLens.","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxray-tracing-deployer\u002FSKILL.md",[],[],{"skillNo":150,"name":151,"nameZh":6,"description":152,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":153,"categories":154,"keywords":155,"publishedAt":19},"01M7ADTVJ7DCBM9CB1FY51GH7J","wellarchitected-workload-auditor","Audits AWS Well-Architected Tool workloads for review staleness, per-pillar high-risk issue counts, milestone tracking gaps, and remediation plan completeness. Emits a deterministic verdict (STALE_REVIEW | HIGH_RISK | CONFIG_GAP | OK) per workload with per-pillar risk breakdown, milestone trend analysis, and specific remediation. Use when reviewing Well-Architected workloads, checking WA review freshness, auditing high-risk issues per pillar, validating milestone coverage, or tracking remediation plans.","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwellarchitected-workload-auditor\u002FSKILL.md",[],[],{"skillNo":157,"name":158,"nameZh":6,"description":159,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":160,"categories":161,"keywords":162,"publishedAt":19},"01M7ADT59G6FTTNZYHT2QRPNNP","wellarchitected-review-operator","Operates AWS Well-Architected Tool reviews end-to-end — creates workloads, runs pillar reviews (operational excellence, security, reliability, performance, cost optimization, sustainability, Prosperity), answers questions with risk-tier rationale, generates reports and improvement plans, creates milestones, and integrates with Trusted Advisor and Well-Architected Labs. Runs deterministic pre-checks (workload existence, lens availability, pillar coverage), emits the exact update-answer \u002F get-consolidated-report CLI behind a CONFIRM gate, and verifies risk-tier transitions. Emits READY | BLOCKED | COMPLETED. Use when creating a workload, answering pillar questions, generating an improvement plan, creating a milestone, or integrating with Trusted Advisor. Triggers: well-architected tool, well architected review, workload review, pillar, operational excellence, security, reliability, performance, cost optimization, sustainability, prosperity, improvement plan, milestone, trusted advisor.","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwellarchitected-review-operator\u002FSKILL.md",[],[],{"skillNo":164,"name":165,"nameZh":6,"description":166,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":167,"categories":168,"keywords":169,"publishedAt":19},"01M7ADSH5JA9QHNPPHQCD7EVA7","wafv2-web-acl-deployer","Provisions AWS WAFv2 Web ACLs with correct production defaults: scope selection (CLOUDFRONT vs REGIONAL), managed rule groups (AWSManagedRulesCommonRuleSet, SQLiRuleSet, LinuxRuleSet, WindowsRuleSet, IPReputationList, BotControlRuleSet, AmazonIpReputationList, ATP), custom rules (byte match, IP set, regex pattern, geo match, size constraint, rate-based), rule priority ordering, logging destinations (Kinesis Firehose, CloudWatch Logs, S3), resource association (ALB, API Gateway, CloudFront), rate-based rules with aggregate keys (IP, forwarded IP), Challenge and CAPTCHA actions, and account takeover prevention. Emits a READY_TO_DEPLOY checklist. Use when creating a Web ACL, attaching managed rules, configuring rate limiting, enabling WAF logging, associating a Web ACL with an ALB\u002FAPI Gateway\u002FCloudFront, or configuring CAPTCHA\u002FChallenge actions. Triggers: create WAF Web ACL, WAFv2, managed rule groups, WAF rate limiting, WAF logging, WAF CAPTCHA, WAF Challenge action, bot control, ATP managed rules.","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwafv2-web-acl-deployer\u002FSKILL.md",[],[],{"skillNo":171,"name":172,"nameZh":6,"description":173,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":174,"categories":175,"keywords":176,"publishedAt":19},"01M7ADRYFAT8R73FBNCHRC573X","wafv2-web-acl-auditor","Audits AWS WAFv2 Web ACL configurations to determine whether the ACL provides effective protection: default-action posture (Allow vs Block), managed-rule-group coverage gaps, rule effectiveness (BLOCK vs COUNT, shadow\u002Fbypass rules, stale exclusions), rate-based rule correctness, logging and visibility configuration, and text-transformation bypass vectors. Emits a deterministic verdict per Web ACL. Use when reviewing a WAFv2 Web ACL for security posture, checking managed-rule coverage, validating rate-limit configuration, auditing WAF logging, or hardening a WAF before production deployment. Triggers: WAF, WAFv2, Web ACL, managed rule group, AWSManagedRules, rate-based rule, CAPTCHA, Challenge, OverrideAction, Count mode, forwarded IP, Bot Control, ATP, text transformation, WAF logging, WAF visibility, OWASP, SQLi, XSS, RFI.","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwafv2-web-acl-auditor\u002FSKILL.md",[],[],{"skillNo":178,"name":179,"nameZh":6,"description":180,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":181,"categories":182,"keywords":183,"publishedAt":19},"01M7ADR8W7G72JX4KFGN03QK8Q","waf-rule-deployer","Provisions AWS WAFv2 rule sets with production defaults: Web ACL creation (CloudFront scope in us-east-1 vs Regional scope), rule groups (managed vs custom) with capacity planning in WCU (Web ACL Capacity Units, 1500 default per ACL), managed rule groups (AWSManagedRulesCommonRuleSet, AWSManagedRulesSQLiRuleSet, AWSManagedRulesAmazonIpReputationList, AWSManagedRulesLinuxRuleSet, AWSManagedRulesWindowsRuleSet, AWSManagedRulesUnixRuleSet), custom rules (byte-match, regex pattern set, geo-match, rate-based), IP set and regex pattern set resources, rule priority ordering (lowest number evaluated first), action types (allow, block, count, CAPTCHA, Challenge), bot control managed rule group, account takeover. Triggers: create WAF rule, WAF managed rule group, WAF custom rule, WAF byte match, WAF geo match, WAF rate based rule, WAF IP set, WAF regex pattern set, WAF WCU budget, WAF CloudFront ACL, WAF logging Kinesis Firehose, WAF bot control, WAF ATP, WAF label matching, WAF Challenge action, WAF CAPTCHA.","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwaf-rule-deployer\u002FSKILL.md",[],[]]