Overview
CdnFactory creates AWS CloudFront distributions with type-safe configuration. It delivers global content with caching, HTTPS, and custom domain support.
CDN is configured automatically when using the Payload pattern. Use
CdnFactory directly when breaking out of patterns or building custom architectures.originType. Use "auto" to detect the origin from a connected Fjall resource, or set "s3", "alb", or "http" explicitly.
Basic Usage
Configuration
Origin Types
Full Configuration Example
Parameters
Core Parameters
The
origin field exists only on the "auto" variant. The "s3", "alb", and "http" variants take bucket, loadBalancer, and domainName respectively (see Origin-Specific Parameters).
Behaviour Parameters
Each behaviour accepts these four fields. CloudFront applies viewer protocol policy, origin request policy, and compression automatically.Origin-Specific Parameters
When using explicit origin types, additional parameters are available:S3 Origin (originType: "s3")
ALB Origin (originType: "alb")
HTTP Origin (originType: "http")
Additional Configuration
Framework-Managed Behaviour Settings
Fjall sets these per-behaviour values internally. They are not configurable through the factory.Cache Policies
Common Patterns
Static Website with S3
Lambda Function URL (Auto-Detection)
originType: "auto", the factory detects the Lambda function URL from the compute resource.
Multi-Origin Setup (OpenNext)
ECS with Load Balancer
The cluster’s load balancer is internet-facing by default. Setrouting to match a path on the shared ALB.
Custom Domain Setup
Prerequisites
- Domain registered and DNS managed (Route 53 recommended)
- ACM certificate in us-east-1 (required for CloudFront)
With Route 53
With External DNS
Create a CNAME record pointing to the CloudFront distribution domain:Accessing CDN Information
Security
Automatic Security Features
- HTTPS only: HTTP automatically redirected to HTTPS
- TLS 1.2+: Modern TLS protocols only
- Origin Access Control: Secure S3 bucket access
- Signed URLs: Optional signed URL support for private content
Best Practices
- Use
originType: "auto"for most cases. Fjall picks the origin from the connected resource. - Cache static assets with the
CACHING_OPTIMIZEDpolicy. - Disable caching for APIs with
CACHING_DISABLEDto return fresh responses. - Create the certificate in us-east-1. CloudFront requires certificates in this region.
Next Steps
Compute Factory
Deploy Lambda and ECS origins
Storage Factory
Configure S3 bucket origins
Payload Pattern
Full-stack deployment with CDN
Network Factory
Configure VPC networking