# Configure S3-compatible access for Starlette

## Summary
Object storage client for a Starlette app on Ample. Verified on Starlette: bucket credentials delivered as encrypted S3_* environment variables and a validated PutObject/GetObject round-trip linked to a database row (upload=ok linked=ok). Build and start: `pip install into .ample/python from requirements.txt`, then `uvicorn from run.py reading PORT on the python-3.12 template.`

## Prerequisites
- A Starlette project (pip install into .ample/python from requirements.txt, then uvicorn from run.py reading PORT on the python-3.12 template)
- 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**  
   `pip install into .ample/python from requirements.txt, then uvicorn from run.py reading PORT on the python-3.12 template; the server must bind 0.0.0.0 on PORT.`

2. **Create the bucket and pass its credentials**  
   Create it once with `ample bucket create`, then pass endpoint, region, bucket and keys with --env; use path-style addressing.  
   Command: `ample deploy . --name  --public --start "python3 run.py" --env S3_ENDPOINT=... --env S3_REGION=... --env S3_BUCKET=... --env S3_ACCESS_KEY_ID=... --env S3_SECRET_ACCESS_KEY=...`

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

## Success Checks
- **app responds on its public URL**  
  - Kind: `http_get`  
  - Path: `/`  
  - Expect: `ample canary starlette patterns`

- **browser-file-uploads check from the example**  
  - Kind: `http_get`  
  - Path: `/p/browser-file-uploads`  
  - Expect: `see the pattern fixture checks`

## Limitations
- Verified on the python-3.12 template at s-1vcpu-1gb; other sizes and Starlette major versions are not verified.
- Region, compliance attestations, and request-duration limits are unknown and not claimed.
- PutObject and GetObject with path-style addressing are verified; other S3 operations are not.

## Cost Estimate
- **Currency:** USD  
- **Monthly Amount:** 5.0  
- **Basis:** size prices from pricing.toml (loaded by the API) at build revision 1ac5595375130d45290090e82ed0f554ccd45405-dirty  
- **Note:** Always-on monthly price of the tested sizes; apps auto-pause when idle. Buckets are allocation-priced per quota and not included.

## Examples
- **Title:** Starlette pattern fixture  
  **Description:** Verified object storage client on Starlette.  
  **Source Reference:** tests/deploy-canaries/starlette-patterns

## Infrastructure Requirements
- **Primitive:** 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.

- **Primitive:** S3-compatible object storage  
  - Status: verified  
  - Summary: Buckets are S3-compatible with issued credentials; PutObject and GetObject are verified by canary. Other S3 operations are not verified.

## Tested Configuration
- **Template:** python-3.12  
- **Runtime:** python  
- **Size:** s-1vcpu-1gb  
- **Install:** `python3 -m pip install --target .ample/python -r requirements.txt`  
- **Start:** `PYTHONPATH=.ample/python:${PYTHONPATH:-} python3 run.py`

## Input Schema
- **Properties:**  
  - **env:** Encrypted environment variables (type: array) 
  - **name:** App name (type: string)  
  - **path:** Project directory or ample.toml service (type: string)  
  - **release_command:** Migration command run before activation (type: string)  
  - **start:** Start command (type: string)

- **Required:** ["env", "name", "path", "start"]

- **Type:** object

## Evidence Summary
- **Kind:** canary_run  
- **Summary:** Starlette pattern fixture deployed on Ample (pip install into .ample/python from requirements.txt, then uvicorn from run.py reading PORT on the python-3.12 template); for this guide: bucket credentials delivered as encrypted S3_* environment variables and a validated PutObject/GetObject round-trip linked to a database row (upload=ok linked=ok).  
- **Observed At:** 2026-09-21T01:21:36Z  
- **Implementation Revision:** 50dbac567d2c5cc8e55e6c748a646be0025d9cfb-dirty (CLI 0.1.21)  
- **Expires At:** 2027-03-20T01:21:36Z  
- **Scope:** {"checks":["/p/browser-file-uploads"],"template":"python-3.12"}

## Last Verified At
- 2026-09-21T01:21:36Z
