# Deliver public assets through CDN for Axum

## Summary
Cdn assets for a Axum app on Ample. Verified on Axum: a versioned, immutable-cached asset uploaded to a published bucket and served from the CDN URL. Build and start: `cargo build --release` in the rust builder image (stable toolchain, Cargo.lock committed, pure-Rust dependencies), then the release binary on the ubuntu-24.04 template reading `PORT` and `DATABASE_URL`.

## Resource Requirements
- **Compute**
- **CDN**

## Infrastructure Requirements
- ### Compute
  - **Status**: Verified
  - **Summary**: Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.

- ### CDN
  - **Status**: Verified
  - **Summary**: The CDN host serves objects from published buckets. It does not front app compute and is not a cache or key-value store.

## Prerequisites
- A Axum project (`cargo build --release` in the rust builder image (stable toolchain, Cargo.lock committed, pure-Rust dependencies), then the release binary on the ubuntu-24.04 template reading `PORT` and `DATABASE_URL`)
- A bucket from `ample bucket create` with credentials passed as encrypted `S3_*` environment variables
- An Ample account token with `servers:write`, `buckets:read`

## Workflow Steps
1. **Build and start**  
   `cargo build --release` in the rust builder image (stable toolchain, Cargo.lock committed, pure-Rust dependencies), then the release binary on the ubuntu-24.04 template reading `PORT` and `DATABASE_URL`; the server must bind 0.0.0.0 on `PORT`.

2. **Publish a bucket for public assets**  
   Publish only the asset bucket; upload versioned keys with an immutable Cache-Control header and build URLs from its public URL.
   
   Command: `ample bucket publish`

3. **Verify**  
   Fetch the live URL and `/p/versioned-static-assets` on the example; on failure read the build and runtime logs.
   
   Command: `ample logs --kind build`

## Limitations
- Verified on the ubuntu-24.04 template at `s-1vcpu-2gb`; other sizes and Axum major versions are not verified.
- Region, compliance attestation and request-duration limits are unknown and not claimed.
- The CDN serves published-bucket objects only; cache rules, purge and TTL control are not verified.

## Cost Estimate
- **Currency**: USD
- **Monthly Amount**: 5.0
- **Basis**: Size prices from `pricing.toml` (loaded by the API) at build revision `1ac5595375130d45290090e82ed0f554ccd45405-dirty`
- **Components**:
  - **Name**: app server
    - **Size**: `s-1vcpu-1gb`
    - **Quantity**: 1.0
    - **Monthly Amount**: 5.0

## Evidence Summary
- **Kind**: Canary run
- **Summary**: Axum pattern fixture deployed on Ample (cargo build --release in the rust builder image (stable toolchain, Cargo.lock committed, pure-Rust dependencies), then the release binary on the ubuntu-24.04 template reading PORT and DATABASE_URL); for this guide: a versioned, immutable-cached asset uploaded to a published bucket and served from the CDN URL.
- **Observed At**: 2026-09-21T02:46:37Z
- **Expires At**: 2027-03-20T02:46:37Z

## Formats
- **HTML**: [Guide](/content/guides/axum/cdn-assets/index.html)
- **Markdown**: [Guide](/content/guides/axum/cdn-assets.md)
- **JSON**: [API Link](https://api.ample.computer/v1/catalog/recipes/page%3Aguides%3Aaxum%3Acdn-assets)

## Next Actions
- **Browse the catalog index**
- **Search published recipes by intent, stack, and constraints**
- **Prepare a side-effect-free deployment plan for an authorized project**
- **Read the existing agent authentication setup**
- **Browse Axum**
- **Browse Add CDN**
- **Browse Versioned static assets**
