CDN Commands
Deploy S3 + CloudFront CDN infrastructure to your AWS account with browser-based image optimization.
Pricing: Free to use. You pay AWS directly for storage (~$0.023/GB/month) and bandwidth (~$0.085/GB). A typical setup costs ~$5-7/month for 10GB storage + 50GB bandwidth.
wraps cdn init
Deploy CDN infrastructure (S3 bucket + CloudFront CDN) to your AWS account. Optionally configure a custom domain for your CDN.
npx @wraps.dev/cli cdn init [options]-r, --region <region>AWS region to deploy infrastructure (default: same as email, or us-east-1)
-d, --domain <domain>Custom CDN domain (e.g., cdn.yourdomain.com). If you have email configured, the CLI will suggest a subdomain based on your email domain.
-p, --provider <provider>Hosting provider: vercel, aws, railway, or other
--previewPreview infrastructure changes without deploying
-y, --yesSkip confirmation prompts
- S3 bucket (
wraps-cdn-{accountId}) with CORS configured - CloudFront distribution for global CDN delivery
- ACM SSL certificate (if custom domain specified)
- IAM permissions for console/dashboard uploads
- Origin Access Control for secure S3 access
Interactive setup:
npx @wraps.dev/cli cdn initWith custom domain:
npx @wraps.dev/cli cdn init --domain cdn.yourdomain.comwraps cdn status
Display the current status of your CDN infrastructure, including CDN domain, S3 bucket, and usage statistics.
npx @wraps.dev/cli cdn status- CDN domain (custom or CloudFront default)
- S3 bucket name and region
- Storage usage (GB)
- Bandwidth usage (GB)
- File count
- Estimated monthly AWS cost
wraps cdn verify
Verify DNS configuration and certificate status for your custom domain. Use this after adding DNS records to confirm everything is working.
npx @wraps.dev/cli cdn verify-r, --region <region>AWS region where CDN is deployed
- CloudFront distribution status (deployed and enabled)
- ACM certificate status (issued and valid)
- Certificate validation DNS records
- Custom domain CNAME pointing to CloudFront
- CloudFront alias configuration
wraps cdn upgrade
Add a custom domain to your CDN after the SSL certificate has been validated. Run this after cdn verify shows the certificate is issued.
npx @wraps.dev/cli cdn upgrade- Adds the custom domain alias to CloudFront distribution
- Associates the validated SSL certificate
- Updates infrastructure state to mark domain as active
wraps cdn sync
Synchronize your local configuration with deployed infrastructure. Useful after CLI updates to apply fixes or when infrastructure state is out of sync.
npx @wraps.dev/cli cdn sync- Re-runs Pulumi deployment with current configuration
- Updates CloudFront, S3, and IAM resources as needed
- Refreshes infrastructure state and stack outputs
wraps cdn destroy
Remove all CDN infrastructure from your AWS account. This is a destructive operation.
npx @wraps.dev/cli cdn destroy [options]-f, --forceSkip confirmation prompt (use with caution)
--previewPreview what would be destroyed without making changes
- S3 bucket and all stored files
- CloudFront distribution
- ACM certificate (if custom domain was configured)
- IAM permissions for CDN access
- Local metadata and Pulumi state
Note: You'll need to manually remove DNS records (CNAME) pointing to CloudFront.
Programmatic Uploads
For server-side uploads, use the AWS SDK directly. Your OIDC role or IAM credentials already have the necessary permissions.
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';const s3 = new S3Client({ region: 'us-east-1' });// Upload a fileawait s3.send(new PutObjectCommand({ Bucket: 'wraps-cdn-123456789012', // From wraps cdn status Key: 'images/hero.webp', Body: buffer, ContentType: 'image/webp', CacheControl: 'public, max-age=31536000, immutable',}));// CDN URL: https://cdn.yourdomain.com/images/hero.webp
