# CDN CLI Commands

Source: https://wraps.dev/docs/cli-reference/cdn

CLI Reference / CDN

# 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.

Usage

terminal.sh

```
npx @wraps.dev/cli cdn init [options]
```

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

`--preview`

Preview infrastructure changes without deploying

`-y, --yes`

Skip confirmation prompts

What It Creates

-   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

Examples

Interactive setup:

terminal.sh

```
npx @wraps.dev/cli cdn init
```

With custom domain:

terminal.sh

```
npx @wraps.dev/cli cdn init --domain cdn.yourdomain.com
```

## wraps cdn status

Display the current status of your CDN infrastructure, including CDN domain, S3 bucket, and usage statistics.

Usage

terminal.sh

```
npx @wraps.dev/cli cdn status
```

What It Displays

-   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.

Usage

terminal.sh

```
npx @wraps.dev/cli cdn verify
```

Options

`-r, --region <region>`

AWS region where CDN is deployed

What It Checks

-   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.

Usage

terminal.sh

```
npx @wraps.dev/cli cdn upgrade
```

What It Does

-   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.

Usage

terminal.sh

```
npx @wraps.dev/cli cdn sync
```

What It Does

-   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.

Usage

terminal.sh

```
npx @wraps.dev/cli cdn destroy [options]
```

Options

`-f, --force`

Skip confirmation prompt (use with caution)

`--preview`

Preview what would be destroyed without making changes

What It Removes

-   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.

Example: Upload from Node.js

upload.ts

```
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
```

[Email Commands](https://wraps.dev/docs/cli-reference/email)[Back to CLI Reference](https://wraps.dev/docs/cli-reference)
