Install any skill in seconds. Free to start, no credit card required.
Get Started Free →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.
.claude/skills/giuseppe-trisciuoglio-aws-cloudformation-cloudfront/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-04 | ✗→✓ | ▲ Improved | 158% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 182% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 144% | 0% |
| case-16 | ✓→✗ | ▼ Worse | 354% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 138% | 0% |
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.
Follow these steps to create CloudFront distributions with CloudFormation:
Validate before deploying:
bashaws cloudformation validate-template --template-body file://template.yaml cfn-lint template.yaml
Specify domain names, ACM certificates, price class, and origin settings:
yamlParameters: DomainName: Type: String Default: cdn.example.com Description: Custom domain name for CloudFront distribution CertificateArn: Type: AWS::ACM::Certificate::Arn Description: ACM certificate ARN for HTTPS PriceClass: Type: String Default: PriceClass_All AllowedValues: - PriceClass_All - PriceClass_100 - PriceClass_200 Description: CloudFront price class OriginDomainName: Type: String Description: Domain name of the origin (ALB or S3)
Add S3 buckets, ALBs, API Gateway, or custom origins. For S3 origins, use OAI (legacy) or OAC (recommended):
yamlResources: # S3 Bucket StaticBucket: Type: AWS::S3::Bucket Properties: BucketName: !Sub "static-assets-${AWS::AccountId}-${AWS::Region}" PublicAccessBlockConfiguration: BlockPublicAcls: true BlockPublicPolicy: true # Origin Access Control (recommended) OriginAccessControl: Type: AWS::CloudFront::OriginAccessControl Properties: OriginAccessControlConfig: Name: !Sub "${AWS::StackName}-oac" OriginAccessControlOriginType: s3 SigningBehavior: always SigningProtocol: sigv4
Configure viewer request/response policies and caching:
yamlResources: CloudFrontDistribution: Type: AWS::CloudFront::Distribution Properties: DistributionConfig: Origins: - Id: S3Origin DomainName: !GetAtt StaticBucket.RegionalDomainName AccessControlId: !Ref OriginAccessControl S3OriginConfig: OriginAccessIdentity: "" DefaultCacheBehavior: TargetOriginId: S3Origin ViewerProtocolPolicy: redirect-to-https AllowedMethods: - GET - HEAD CachedMethods: - GET - HEAD Compress: true CachePolicyId: !Ref CachePolicy
Create path-specific caching rules for different content types:
yamlResources: ApiCachePolicy: Type: AWS::CloudFront::CachePolicy Properties: CachePolicyConfig: Name: !Sub "${AWS::StackName}-api-cache" DefaultTTL: 300 MaxTTL: 600 MinTTL: 60 CloudFrontDistribution: Type: AWS::CloudFront::Distribution Properties: DistributionConfig: CacheBehaviors: - PathPattern: "/api/*" TargetOriginId: ApiOrigin CachePolicyId: !GetAtt ApiCachePolicy.Id AllowedMethods: - GET - HEAD - OPTIONS - PUT - POST
Implement security headers and WAF integration:
yamlResources: SecurityHeadersPolicy: Type: AWS::CloudFront::ResponseHeadersPolicy Properties: ResponseHeadersPolicyConfig: Name: !Sub "${AWS::StackName}-security-headers" SecurityHeadersConfig: StrictTransportSecurity: AccessControlMaxAgeSec: 31536000 IncludeSubdomains: true Override: true FrameOptions: FrameOption: DENY Override: true WAFWebACL: Type: AWS::WAFv2::WebACL Properties: Name: !Sub "${AWS::StackName}-waf" Scope: CLOUDFRONT DefaultAction: Allow: {}
Configure functions for request/response manipulation:
yamlResources: RewritePathFunction: Type: AWS::CloudFront::Function Properties: Name: !Sub "${AWS::StackName}-rewrite-path" FunctionCode: | function handler(event) { var request = event.request; // Function code here return request; } Runtime: cloudfront-js-1.0 AutoPublish: true
Set up logging and access logs to S3:
yamlResources: AccessLogsBucket: Type: AWS::S3::Bucket Properties: BucketName: !Sub "cloudfront-logs-${AWS::AccountId}" CloudFrontDistribution: Type: AWS::CloudFront::Distribution Properties: DistributionConfig: Logging: Bucket: !Ref AccessLogsBucket Prefix: cloudfront-logs/ IncludeCookies: false
Export distribution details for cross-stack references:
yamlOutputs: DistributionDomainName: Description: CloudFront distribution domain name Value: !GetAtt CloudFrontDistribution.DomainName Export: Name: !Sub "${AWS::StackName}-DistributionDomainName" DistributionId: Description: CloudFront distribution ID Value: !Ref CloudFrontDistribution Export: Name: !Sub "${AWS::StackName}-DistributionId"
us-east-1 (N. Virginia) for CloudFrontyamlAWSTemplateFormatVersion: "2010-09-09" Resources: S3Bucket: Type: AWS::S3::Bucket Properties: BucketName: !Sub "cdn-static-${AWS::AccountId}" PublicAccessBlockConfiguration: BlockPublicAcls: true BlockPublicPolicy: true OriginAccessControl: Type: AWS::CloudFront::OriginAccessControl Properties: OriginAccessControlConfig: Name: !Sub "${AWS::StackName}-oac" OriginAccessControlOriginType: s3 SigningBehavior: always SigningProtocol: sigv4 CloudFrontDistribution: Type: AWS::CloudFront::Distribution Properties: DistributionConfig: Enabled: true DefaultRootObject: index.html Origins: - Id: S3Origin DomainName: !GetAtt S3Bucket.RegionalDomainName AccessControlId: !Ref OriginAccessControl DefaultCacheBehavior: TargetOriginId: S3Origin ViewerProtocolPolicy: redirect-to-https Compress: true CachePolicyId: 658327ea-f89d-4fab-a63d-7e88639e58f6 PriceClass: PriceClass_All HttpVersion: http2and3 Outputs: DistributionDomainName: Value: !GetAtt CloudFrontDistribution.DomainName
yamlResources: CachePolicyApi: Type: AWS::CloudFront::CachePolicy Properties: CachePolicyConfig: Name: !Sub "${AWS::StackName}-api" DefaultTTL: 300 MaxTTL: 600 MinTTL: 60 CloudFrontDistribution: Type: AWS::CloudFront::Distribution Properties: DistributionConfig: Origins: - Id: S3Origin DomainName: !GetAtt StaticBucket.RegionalDomainName AccessControlId: !Ref OriginAccessControl - Id: ApiOrigin DomainName: !GetAtt ApiLoadBalancer.DNSName CustomOriginConfig: OriginProtocolPolicy: https-only HTTPPort: 80 HTTPSPort: 443 CacheBehaviors: - PathPattern: "/api/*" TargetOriginId: ApiOrigin CachePolicyId: !GetAtt CachePolicyApi.Id ViewerProtocolPolicy: https-only - PathPattern: "/static/*" TargetOriginId: S3Origin CachePolicyId: 658327ea-f89d-4fab-a63d-7e88639e58f6
For detailed implementation guidance, see:
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | pass→pass | 10,331 | 8,247 | -20% | 1 | 1 | 0% | 2,094 | 4,981 | +138% | 0 | 0 | — |
case-02 | pass→pass | 7,324 | 6,516 | -11% | 1 | 1 | 0% | 1,248 | 4,552 | +265% | 0 | 0 | — |
case-03 | pass→pass | 10,827 | 8,281 | -24% | 1 | 1 | 0% | 2,027 | 4,887 | +141% | 0 | 0 | — |
case-04 | fail→pass | 11,575 | 8,156 | -30% | 1 | 1 | 0% | 1,830 | 4,724 | +158% | 0 | 0 | — |
case-05 | fail→fail | 10,115 | 6,028 | -40% | 1 | 1 | 0% | 1,774 | 4,497 | +153% | 0 | 0 | — |
case-06 | pass→pass | 5,717 | 5,307 | -7% | 1 | 1 | 0% | 1,063 | 4,385 | +313% | 0 | 0 | — |
case-07 | fail→pass | 7,591 | 3,687 | -51% | 1 | 1 | 0% | 1,430 | 4,035 | +182% | 0 | 0 | — |
case-08 | pass→pass | 6,079 | 9,400 | +55% | 1 | 1 | 0% | 1,039 | 4,392 | +323% | 0 | 0 | — |
case-09 | pass→pass | 6,750 | 3,307 | -51% | 1 | 1 | 0% | 1,220 | 4,010 | +229% | 0 | 0 | — |
case-10 | pass→pass | 3,976 | 4,353 | +9% | 1 | 1 | 0% | 665 | 4,154 | +525% | 0 | 0 | — |
case-11 | fail→pass | 11,462 | 6,608 | -42% | 1 | 1 | 0% | 1,825 | 4,450 | +144% | 0 | 0 | — |
case-12 | pass→pass | 7,220 | 5,260 | -27% | 1 | 1 | 0% | 1,138 | 4,242 | +273% | 0 | 0 | — |
case-13 | pass→pass | 4,014 | 3,038 | -24% | 1 | 1 | 0% | 606 | 3,882 | +541% | 0 | 0 | — |
case-14 | pass→pass | 5,030 | 4,371 | -13% | 1 | 1 | 0% | 854 | 4,103 | +380% | 0 | 0 | — |
case-15 | pass→pass | 8,912 | 3,927 | -56% | 1 | 1 | 0% | 1,414 | 3,982 | +182% | 0 | 0 | — |
case-16 | pass→fail | 5,896 | 6,349 | +8% | 1 | 1 | 0% | 965 | 4,381 | +354% | 0 | 0 | — |
case-17 | pass→pass | 3,322 | 4,995 | +50% | 1 | 1 | 0% | 573 | 4,055 | +608% | 0 | 0 | — |
case-18 | pass→pass | 3,518 | 3,325 | -5% | 1 | 1 | 0% | 619 | 3,988 | +544% | 0 | 0 | — |
case-19 | pass→pass | 4,347 | 3,218 | -26% | 1 | 1 | 0% | 675 | 3,916 | +480% | 0 | 0 | — |
case-20 | pass→pass | 6,380 | 6,066 | -5% | 1 | 1 | 0% | 1,116 | 4,548 | +308% | 0 | 0 | — |
case-21 | pass→pass | 7,898 | 7,456 | -6% | 1 | 1 | 0% | 1,569 | 4,937 | +215% | 0 | 0 | — |
case-22 | pass→pass | 6,454 | 6,697 | +4% | 1 | 1 | 0% | 1,164 | 4,767 | +310% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 22 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.