Skip to main content
This guide walks you through deploying Wraps CDN infrastructure: an S3 bucket backed by a CloudFront distribution, with an optional custom domain and SSL certificate.

Prerequisites

  • Node.js 20+
  • AWS credentials configured (guide)
  • A custom domain (optional, but recommended for production)

What gets deployed

Running wraps cdn init creates the following resources in your AWS account:
ResourceDetails
S3 bucketNamed wraps-cdn-*, private, with optional versioning
CloudFront distributionGlobal edge network with configurable price class
ACM certificateSSL certificate for custom domains (if configured)
Origin Access ControlRestricts S3 access to CloudFront only
IAM roleLeast-privilege role for upload access
1

Deploy infrastructure

Run the following command. No install required.
npx @wraps.dev/cli cdn init
The CLI will prompt you for:
  • 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
To pass options directly:
npx @wraps.dev/cli cdn init --region us-east-1 --domain cdn.yourapp.com
To preview what will be created without deploying:
npx @wraps.dev/cli cdn init --preview
Deployment takes about 2–3 minutes. When complete, the CLI prints your S3 bucket name, CloudFront distribution domain, and IAM role ARN.
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.
2

Verify DNS and certificate status

Check the current status of your CDN, DNS records, and SSL certificate:
npx @wraps.dev/cli cdn verify
If you specified a custom domain, the CLI prints the DNS records you need to add. You’ll need:
  1. Certificate validation records — CNAME records for ACM to validate your SSL certificate
  2. CDN domain record — a CNAME pointing your custom domain to the CloudFront distribution domain
Example records:
# 1. SSL certificate validation
_abc123.cdn.yourapp.com  CNAME  _xyz456.acm-validations.aws.

# 2. CDN domain (add AFTER certificate is validated)
cdn.yourapp.com  CNAME  d1234abcd.cloudfront.net
Add the CDN domain CNAME only after the SSL certificate has been validated. Adding it before will cause SSL errors. Certificate validation typically takes a few minutes but can take up to 30 minutes.
If your DNS is managed by Route 53, the CLI can create DNS records automatically during wraps cdn init.
3

Upgrade with custom domain

Once your SSL certificate has been validated, run the upgrade command to attach the custom domain to your CloudFront distribution:
npx @wraps.dev/cli cdn upgrade
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:
npx @wraps.dev/cli cdn status
4

Use your CDN

Upload files to S3 and serve them through CloudFront. Access your assets at:
# Default CloudFront domain
https://d1234abcd.cloudfront.net/your-file.jpg

# Custom domain (after DNS and cert are configured)
https://cdn.yourapp.com/your-file.jpg
To sync changes after updating configuration:
npx @wraps.dev/cli cdn sync

CDN configuration options

When using the custom preset, you can configure:
OptionDescription
Price classPriceClass_All (global, 400+ edges), PriceClass_200 (most regions), PriceClass_100 (US, Canada, Europe)
Origin ShieldReduces S3 requests by ~80% by adding a caching layer in front of the origin
Geo restrictionAllow or block specific countries using ISO 3166-1 alpha-2 codes
S3 versioningKeeps previous versions of replaced files
RetentionAuto-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.

Build docs developers (and LLMs) love