CDN CLI Commands
CLI commands for managing CDN infrastructure.
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.
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
wraps-cdn-{accountId}) with CORS configuredInteractive setup:
npx @wraps.dev/cli cdn initWith custom domain:
npx @wraps.dev/cli cdn init --domain cdn.yourdomain.comDisplay the current status of your CDN infrastructure, including CDN domain, S3 bucket, and usage statistics.
npx @wraps.dev/cli cdn statusVerify 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
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 upgradeSynchronize 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 syncRemove 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
Note: You'll need to manually remove DNS records (CNAME) pointing to CloudFront.
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