Prerequisites
- Node.js 20+
- AWS credentials configured (guide)
- A custom domain (optional, but recommended for production)
What gets deployed
Runningwraps cdn init creates the following resources in your AWS account:
| Resource | Details |
|---|---|
| S3 bucket | Named wraps-cdn-*, private, with optional versioning |
| CloudFront distribution | Global edge network with configurable price class |
| ACM certificate | SSL certificate for custom domains (if configured) |
| Origin Access Control | Restricts S3 access to CloudFront only |
| IAM role | Least-privilege role for upload access |
Deploy infrastructure
Run the following command. No install required.The CLI will prompt you for:To preview what will be created without deploying:Deployment takes about 2–3 minutes. When complete, the CLI prints your S3 bucket name, CloudFront distribution domain, and IAM role ARN.
- Hosting provider — Vercel, AWS, Railway, or other
- AWS region — defaults to your configured region
- Configuration preset — production (recommended) or starter
- Custom CDN domain — e.g.,
cdn.yourapp.com(optional) - Estimated usage — for cost estimation
If you specified a custom domain, the CLI will also provision an ACM SSL certificate. Certificate validation requires adding DNS records before the domain becomes active.
Verify DNS and certificate status
Check the current status of your CDN, DNS records, and SSL certificate:If you specified a custom domain, the CLI prints the DNS records you need to add. You’ll need:
- Certificate validation records — CNAME records for ACM to validate your SSL certificate
- CDN domain record — a CNAME pointing your custom domain to the CloudFront distribution domain
Upgrade with custom domain
Once your SSL certificate has been validated, run the upgrade command to attach the custom domain to your CloudFront distribution:This updates the CloudFront distribution to serve traffic for your custom domain using the validated certificate.Check the current CDN configuration and status at any time:
CDN configuration options
When using thecustom preset, you can configure:
| Option | Description |
|---|---|
| Price class | PriceClass_All (global, 400+ edges), PriceClass_200 (most regions), PriceClass_100 (US, Canada, Europe) |
| Origin Shield | Reduces S3 requests by ~80% by adding a caching layer in front of the origin |
| Geo restriction | Allow or block specific countries using ISO 3166-1 alpha-2 codes |
| S3 versioning | Keeps previous versions of replaced files |
| Retention | Auto-delete files after 30, 60, 90, 180 days, or 1 year |
Next steps
CLI CDN reference
Full reference for every
wraps cdn command and flag.Domain setup guide
Configure DNS records for custom domains.
AWS credentials
Configure credentials for local development and CI/CD.
OIDC for Vercel
Authenticate from Vercel without storing AWS credentials.
