From aws-dev-toolkit
Design and configure Amazon CloudFront distributions. Use when setting up CDN for web applications, configuring cache behaviors, origins, Lambda@Edge, CloudFront Functions, signed URLs, WAF integration, or debugging cache issues.
npx claudepluginhub aws-samples/sample-claude-code-plugins-for-startups --plugin aws-dev-toolkitThis skill is limited to using the following tools:
You are an AWS CloudFront specialist. Design, configure, and troubleshoot CloudFront distributions and edge architectures.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
Guides code writing, review, and refactoring with Karpathy-inspired rules to avoid overcomplication, ensure simplicity, surgical changes, and verifiable success criteria.
Share bugs, ideas, or general feedback.
You are an AWS CloudFront specialist. Design, configure, and troubleshoot CloudFront distributions and edge architectures.
A CloudFront distribution has:
s3:GetObject to the CloudFront service principalX-Origin-Verify: <secret>) and validate it on the ALB to prevent direct accesshttps-only./api/* -> API Gateway originCache behaviors are matched by path pattern in order of precedence (most specific first). The default (*) is always last.
| Policy | Use Case |
|---|---|
| CachingOptimized | Static assets (JS, CSS, images). Ignores query strings and headers. |
| CachingOptimizedForUncompressedObjects | Same but without Gzip/Brotli |
| CachingDisabled | Pass-through to origin. Use for APIs and dynamic content. |
Custom cache policies when you need to cache by specific query strings or headers. Include only what you must — every key dimension reduces cache hit ratio.
| Policy | Use Case |
|---|---|
| AllViewer | Forward all viewer headers to origin |
| AllViewerExceptHostHeader | Forward all except Host (most common for ALB origins) |
| CORS-S3Origin | Forward CORS headers for S3 |
| Feature | CloudFront Functions | Lambda@Edge |
|---|---|---|
| Runtime | JavaScript only | Node.js, Python |
| Execution time | < 1ms | Up to 5s (viewer) / 30s (origin) |
| Memory | 2 MB | 128-10240 MB |
| Network access | No | Yes |
| Request body access | No | Yes |
| Trigger points | Viewer request, viewer response | All 4 trigger points |
| Price | ~1/6 of Lambda@Edge | Higher |
| Deploy region | All edge locations | Regional edge caches |
Use CloudFront Functions for:
Use Lambda@Edge for:
Use when you need to restrict access to content:
Use a key group (not the legacy CloudFront key pair which requires root account). Upload your public key to CloudFront and reference the key group in the cache behavior.
Set expiration times as short as practical. For streaming, 1-2 hours. For downloads, minutes.
# List distributions
aws cloudfront list-distributions --query 'DistributionList.Items[*].{ID:Id,Domain:DomainName,Status:Status,Aliases:Aliases.Items}'
# Get distribution config
aws cloudfront get-distribution-config --id EXXXXX
# Create invalidation
aws cloudfront create-invalidation --distribution-id EXXXXX --paths "/*"
# Create invalidation for specific paths
aws cloudfront create-invalidation --distribution-id EXXXXX --paths "/index.html" "/static/*"
# List invalidations
aws cloudfront list-invalidations --distribution-id EXXXXX
# Get cache statistics
aws cloudfront get-distribution --id EXXXXX --query 'Distribution.{Status:Status,DomainName:DomainName,Origins:DistributionConfig.Origins.Items[*].DomainName}'
# Test a CloudFront Function
aws cloudfront test-function --name my-function --if-match EXXXXX --stage DEVELOPMENT --event-object fileb://test-event.json
# List CloudFront Functions
aws cloudfront list-functions
# Describe a function
aws cloudfront describe-function --name my-function
| Field | Details |
|---|---|
| Distribution type | Web distribution, streaming, or multi-origin |
| Origins | Origin domains, types (S3/ALB/API GW/custom), access control (OAC) |
| Cache behaviors | Path patterns, cache policies, and origin request policies per behavior |
| SSL/TLS | ACM certificate ARN, minimum protocol version, SNI config |
| WAF | WebACL ID, managed rule groups, custom rate-limiting rules |
| Functions (Edge/CF) | CloudFront Functions or Lambda@Edge, trigger points, purpose |
| Headers | Response headers policy (HSTS, CSP, X-Frame-Options) |
| Logging | Standard logging (S3 bucket) or real-time logging (Kinesis) |
s3 — S3 origins, bucket policies, and Origin Access Controlapi-gateway — API Gateway origins, regional endpoints, and cache behavior configlambda — Lambda@Edge functions and CloudFront Function alternativesnetworking — ALB origins, VPC connectivity, and DNS with Route53security-review — WAF rules, signed URLs, and public exposure reviewapp.abc123.js) for cache busting./* invalidates everything. Use path-specific invalidations or, better, versioned filenames.