giuseppe-trisciuoglio/developer-kit/aws-cloudformation-cloudfront
Claude Code and agent skill by giuseppe-trisciuoglio/developer-kit
- community
Checking that the SKILL.md file is still in the repository.
Provides AWS CloudFormation patterns for CloudFront distributions, origins (ALB, S3, Lambda@Edge, VPC Origins), CacheBehaviors, Functions, SecurityHeaders, parameters, Outputs and cross-stack references. Use when creating CloudFront distributions with CloudFormation, configuring multiple origins, implementing caching strategies, managing custom domains with ACM, configuring WAF, and optimizing performance.
Install
npx vskill@latest install giuseppe-trisciuoglio/developer-kit/aws-cloudformation-cloudfrontSKILL.md
The same SKILL.md was published earlier as giuseppe-trisciuoglio/developer-kit/aws-cloudformation-cloudfront.
AWS CloudFormation CloudFront CDN
Overview
Create production-ready CDN infrastructure using AWS CloudFormation templates. This skill covers CloudFront distributions, multiple origins (ALB, S3, API Gateway, Lambda@Edge, VPC Origins), CacheBehaviors, Functions, SecurityHeaders, and best practices for parameters, outputs, and cross-stack references.
When to Use
- Creating CloudFront distributions with CloudFormation
- Configuring origins (ALB, S3, Lambda@Edge, VPC Origins) with path patterns
- Implementing caching with CacheBehaviors and Cache Policies
- Configuring custom domains with ACM and SecurityHeaders
- Integrating WAF with CloudFront distributions
Instructions
Follow these steps to create CloudFront distributions with CloudFormation:
1. Define Distribution Parameters
Validate before deploying:
Specify domain names, ACM certificates, price class, and origin settings:
2. Configure Origins
Add S3 buckets, ALBs, API Gateway, or custom origins. For S3 origins, use OAI (legacy) or OAC (recommended):
3. Set Up Default Cache Behavior
Configure viewer request/response policies and caching:
4. Add Additional Cache Behaviors
Create path-specific caching rules for different content types:
5. Configure Security Settings
Implement security headers and WAF integration:
6. Add CloudFront Functions
Configure functions for request/response manipulation:
7. Configure Monitoring
Set up logging and access logs to S3:
8. Create Outputs
Export distribution details for cross-stack references:
Best Practices
Security
- Always use HTTPS with minimum TLS 1.2
- Implement SecurityHeaders with HSTS, XSS protection
- Use WAF for protection against common attacks
- Configure appropriate Access-Control for CORS
- Limit origin access with OAI/OAC
- Use Signed URLs for private content
- Implement rate limiting
- Configure geo-restrictions if needed
Performance
- Use appropriate PriceClass to optimize costs
- Configure Cache TTL based on content type
- Enable compression (Gzip/Brotli)
- Use CloudFront Functions for lightweight operations
- Optimize header forwarding (do not forward unnecessary headers)
- Consider Origin Shield to reduce load on origins
- Use multiple origins with path patterns
Monitoring
- Enable CloudWatch metrics and alarms
- Configure real-time logs for troubleshooting
- Monitor cache hit ratio
- Configure alerts for error rate and latency
- Use CloudFront reports for traffic analysis
Deployment
- Use change sets before deployment
- Test templates with cfn-lint
- Organize stacks by lifecycle and ownership
- Implement blue/green deployments with weighted aliases
- Use StackSets for multi-region deployment
Template Structure
- Use AWS-specific parameter types (AWS::ACM::Certificate::Arn, AWS::S3::Bucket::RegionalDomainName)
- Implement parameter constraints (MinLength, MaxLength, AllowedValues, AllowedPattern)
- Use Conditions for environment-specific configuration
- Leverage Mappings for region-specific configuration
- Apply Metadata for parameter grouping and labels
- Use nested stacks for modularity
Cache Strategy
- Use Cache Policies for different content types
- Configure Origin Request Policies to control what's sent to origin
- Set appropriate TTL values:
- Static assets: 86400-31536000 seconds (1 day to 1 year)
- API responses: 60-600 seconds (1-10 minutes)
- Dynamic content: 0 seconds (no caching)
- Enable compression for text-based content
- Use versioned paths for cache busting
Constraints and Warnings
- ACM certificates: Must be in
us-east-1(N. Virginia) for CloudFront - Limits: Max 200 distributions per AWS account, 25 origins per distribution, 25 cache behaviors per distribution
- Deployment time: CloudFront distributions take up to 30 minutes to deploy; plan accordingly
- Certificate requirements: Max 100 alternate domain names per distribution; include default domain for SSL
- OAI deprecation: Prefer Origin Access Control (OAC) over Origin Access Identity (OAI) for S3 origins
- Lambda@Edge limits: 128MB memory, 30s timeout for viewer request/response; separate limits apply for origin requests
- Change sets: Always use change sets before deploying to preview resource changes and avoid accidental deletions
- Drift detection: CloudFormation does not detect drift for CloudFront distributions — manage all settings in templates
Examples
Minimal S3 Static Site Distribution
Multi-Origin with Cache Behaviors
References
For detailed implementation guidance, see:
- [template-structure.md](references/template-structure.md) - Complete template structure, AWS-specific parameter types, parameter constraints, SSM parameter references, metadata for parameter grouping, transform for macros, conditions for environment-specific configuration, nested stacks, and cross-stack references with export/import patterns
- [origins.md](references/origins.md) - Origin configuration including S3 origins with OAI/OAC, ALB origins with security groups, API Gateway origins (REST and HTTP APIs), Lambda@Edge origins, VPC origins with Global Accelerator, custom origins, and multi-origin configurations with path patterns
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/developer-kit-aws/skills/aws-cloudformation/aws-cloudformation-cloudfront/SKILL.md
Popularity
- Repository stars
- 298
- Repository forks
- 35
- 7-day trend score
- 29
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/giuseppe-trisciuoglio/developer-kit/aws-cloudformation-cloudfront)