page:recipes:form collection:fastapi:data imports
Host form collection with FastAPI: structured data imports
Deploy a form collection built with FastAPI on Ample using the bulk import staging pattern. Compute runs the app in an isolated microVM behind a public HTTPS URL, a managed PostgreSQL 16 database is auto-provisioned and injected as DATABASE_URL, a private S3-compatible bucket holds objects with credentials delivered as encrypted environment variables. Verified on FastAPI: a CSV staged as an object, row-level validation with per-row errors recorded, and a restart-safe import keyed by import id (imported=2 rejected=1 restart=ok). Not separately tested: your import format, mapping and conflict rules; treat the form collection-specific behavior as your application code.
Representative Queries
- Host form collection with FastAPI: structured data imports
- Where can I host Form collection built with FastAPI?
- I need a workload-specific import mapping, conflict rules and restart behavior.
Parent Resources
Resource Requirements
- Compute: Apps run in isolated x86_64 Firecracker microVMs.
- Postgres: Managed PostgreSQL 16 runs in its own microVM.
- S3-compatible object storage: Buckets are S3-compatible with issued credentials.
Workflow Steps
- 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.
- Implement the pattern on PostgreSQL: The fixture's module implements bulk import staging: a CSV staged as an object, row-level validation with per-row errors recorded, and a restart-safe import keyed by import id (imported=2 rejected=1 restart=ok). Copy the approach into your schema; keep migrations idempotent and run them with --release-command.
- Wire object storage: Create the bucket(s), then pass endpoint, region, bucket and keys as --env values. Use path-style addressing. Keep private data in an unpublished bucket.
- Deploy: Run the synchronous deploy once and read the result. Re-running with no change is a no-op.
- Verify: Fetch the live URL and the pattern self-test route(s); then run your own checks. On failure, read logs.
Examples
- FastAPI pattern fixture: Multi-pattern FastAPI app whose bulk import staging module was checked live.
Success Checks
- App responds on its public URL
- Bulk-import-staging self-test
Limitations
- Verified on the python-3.12 template at s-1vcpu-1gb.
Cost Estimate
- Monthly Cost: $10
- App server s-1vcpu-1gb: $5
- Managed PostgreSQL database s-1vcpu-1gb: $5