{"catalogRevision":"cat_726f873af6f566cc","recipeId":"page:guides:fastapi:object-client","recipeRevision":"r1","canonicalPath":"/guides/fastapi/object-client","label":"Configure S3-compatible access for FastAPI","title":"How to use S3-compatible storage from a FastAPI app on Ample","family":"Framework operation","summary":"Configure S3-compatible access for a FastAPI app on Ample. Create a bucket with `ample bucket create`, pass its endpoint, region, bucket name and keys as encrypted environment variables, and use boto3 with Config(s3={'addressing_style': 'path'}). The app writes and reads objects through the S3-compatible endpoint; the bucket stays private.","representativeQueries":["Configure S3-compatible access for FastAPI","Where can I host Configure S3-compatible access built with FastAPI?","I need exact S3 endpoint, credentials, operation requirements and an upload/download verification."],"breadcrumbIds":["discovery","stack","stack:frameworks","stack:framework-fastapi","page:guides:fastapi:object-client"],"breadcrumbs":[{"id":"discovery","label":"Agent hosting discovery","canonicalPath":"/discover/discovery","kind":"root"},{"id":"stack","label":"Frameworks and execution targets","canonicalPath":"/discover/stack","kind":"facet"},{"id":"stack:frameworks","label":"Frameworks","canonicalPath":"/discover/stack/frameworks","kind":"group"},{"id":"stack:framework-fastapi","label":"FastAPI","canonicalPath":"/discover/stack/framework-fastapi","kind":"atom"},{"id":"page:guides:fastapi:object-client","label":"Configure S3-compatible access for FastAPI","canonicalPath":"/guides/fastapi/object-client","kind":"recipe"}],"parentIds":["stack:framework-fastapi","intent:connect-app-to-storage","pattern:browser-file-uploads"],"parents":[{"id":"stack:framework-fastapi","label":"FastAPI","canonicalPath":"/discover/stack/framework-fastapi","kind":"atom"},{"id":"intent:connect-app-to-storage","label":"Connect app to storage","canonicalPath":"/discover/intent/connect-app-to-storage","kind":"atom"},{"id":"pattern:browser-file-uploads","label":"Browser file uploads","canonicalPath":"/discover/pattern/browser-file-uploads","kind":"atom"}],"resourceRequirements":["primitive:compute","primitive:s3-compatible-object-storage"],"infrastructureRequirements":[{"primitiveId":"primitive:compute","label":"Compute","canonicalPath":"/discover/primitive/compute","status":"verified","summary":"Apps run in isolated x86_64 Firecracker microVMs; sizes are the priced VM sizes."},{"primitiveId":"primitive:s3-compatible-object-storage","label":"S3-compatible object storage","canonicalPath":"/discover/primitive/s3-compatible-object-storage","status":"verified","summary":"Buckets speak the S3 API with SigV4 credentials Ample Computer issues; `ample bucket upload-url` returns a presigned upload URL. PutObject and GetObject are checked by canary."}],"framework":"FastAPI","workload":"Configure S3-compatible access","releaseStatus":"published","supportStatus":"verified","executionStatus":"ready","docsOnly":false,"prerequisites":["An S3 client in the app (boto3 with Config(s3={'addressing_style': 'path'})) reading S3_ENDPOINT, S3_REGION, S3_BUCKET, S3_ACCESS_KEY_ID and S3_SECRET_ACCESS_KEY","A bucket created with `ample bucket create <name>` and its credentials from `ample bucket credentials <name>`","An Ample account token with servers:write and buckets:read"],"testedConfiguration":{"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"},"inputSchema":{"additionalProperties":false,"properties":{"env":{"description":"Encrypted environment variables: S3_ENDPOINT, S3_REGION, S3_BUCKET, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY from `ample bucket credentials` (and S3_PUBLIC_URL for a published bucket)","items":{"pattern":"^[A-Z][A-Z0-9_]*=.*$","type":"string"},"maxItems":50,"type":"array"},"name":{"description":"App name (lowercase, digits and dashes)","maxLength":63,"minLength":1,"pattern":"^[a-z0-9-]+$","type":"string"},"path":{"description":"Project directory to deploy, or one service name from ample.toml","maxLength":512,"minLength":1,"type":"string"},"size":{"description":"VM size; omit to let Ample pick a runtime-safe size","enum":["s-1vcpu-256mb","s-1vcpu-1gb","s-1vcpu-2gb","s-2vcpu-2gb","s-2vcpu-4gb"],"type":"string"},"start":{"description":"Start command override when detection cannot infer it (Python apps pass one explicitly)","maxLength":512,"type":"string"}},"required":["env","name","path","start"],"type":"object"},"outputSchema":null,"workflowSteps":[{"title":"Create the bucket","body":"Create it once and keep the issued credentials out of the repository.","command":"ample bucket create --name <bucket-name>"},{"title":"Configure the client with path-style addressing","body":"Use boto3 with Config(s3={'addressing_style': 'path'}) (path-style addressing)."},{"title":"Deploy with the credentials as encrypted env","body":"Pass the five S3_* variables with --env; they are stored encrypted and reused on redeploys.","command":"ample deploy . --name <app-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=..."},{"title":"Test through the app","body":"Expose a route (/storage) that writes then reads an object and reports s3=ok."},{"title":"Verify","body":"Fetch the live URL and run the success checks below. On failure read the build log, then the runtime log, fix the cause and deploy again; do not blind-retry.","command":"ample logs <deployment_id> --kind build"}],"examples":[{"title":"FastAPI bucket canary","description":"Write and read an object with the injected credentials.","sourceRef":"tests/deploy-canaries/fastapi-bucket-uploads"}],"successChecks":[{"description":"object write and read succeed","kind":"http_get","path":"/storage","expect":"s3=ok"}],"limitations":["Verified on the python-3.12 template at s-1vcpu-1gb.","Buckets speak the standard S3 API (PutObject and GetObject with path-style addressing are checked by the fixtures); `ample bucket upload-url` returns presigned upload URLs.","Bucket credentials are passed as encrypted environment variables; the catalog never creates the bucket for you (use `ample bucket create`).","Storage counts what you store, within your plan's allowance; the estimate below covers compute only."],"costEstimate":{"currency":"USD","monthlyAmount":5.0,"authoritative":true,"basis":"size prices from pricing.toml (loaded by the API) at build revision 3a3dfe06151688a20d397caac2aa66e562c23eb0","components":[{"name":"app server","size":"s-1vcpu-1gb","quantity":1.0,"monthlyAmount":5.0}],"note":"Compute only. Buckets are allocation-priced per quota and capped by the plan; see `ample usage`."},"evidenceSummary":[{"kind":"canary_run","summary":"FastAPI app using boto3 (path-style addressing) with injected bucket credentials: put_object then get_object returned s3=ok.","observedAt":"2026-11-06T00:38:14Z","implementationRevision":"7360fc06ef21","expiresAt":"2027-05-05T00:38:14Z","scope":{"cliVersion":"0.1.37","platform":"hosted","template":"python-3.12"}},{"kind":"canary_run","summary":"ample bucket create issued credentials; PutObject and GetObject succeeded through the public S3 endpoint; publish exposed the object at its public URL with an ETag; unpublish and delete cleaned up.","observedAt":"2026-11-05T22:38:23Z","implementationRevision":"da3e37255e5a","expiresAt":"2027-05-04T22:38:23Z","scope":{"cliVersion":"0.1.37","platform":"hosted","template":"python-3.12"}}],"lastVerifiedAt":"2026-11-06T00:38:14Z","mcpBinding":{"registryRef":"mcp:ample_deploy","toolName":"ample_deploy","schemaHash":"0802c329be823fa0695460cf73206d47a6fa0efa57417c386c34b6614a92ea5f","observedAt":"2026-11-06T06:16:19.461833707+00:00","implementationRevision":"4558e9477d09","requiredScopes":["servers:write","buckets:read"],"bindingState":"current"},"unknowns":[],"formats":{"html":"https://ample.computer/guides/fastapi/object-client","markdown":"https://ample.computer/guides/fastapi/object-client.md","json":"https://api.ample.computer/v1/catalog/recipes/page%3Aguides%3Afastapi%3Aobject-client"},"nextActions":[{"actionId":"browse-catalog","label":"Browse the catalog index","operationId":"catalog_index","method":"GET","relativePath":"/v1/catalog","origin":"api","parameters":{},"requiresAuthentication":false,"requiresApproval":false},{"actionId":"search-recipes","label":"Search published recipes by intent, stack and constraints","operationId":"search_recipes","method":"POST","relativePath":"/v1/catalog/search","origin":"api","parameters":{"body":{"limit":5,"query":"Configure S3-compatible access for FastAPI"}},"requiresAuthentication":false,"requiresApproval":false},{"actionId":"plan:page:guides:fastapi:object-client","label":"Prepare a side-effect-free deployment plan for an authorized project","operationId":"plan_deployment","method":"POST","relativePath":"/v1/catalog/plan","origin":"api","parameters":{"body":{"inputs":{},"projectId":"<workspace or server id you own>","recipeId":"page:guides:fastapi:object-client","recipeRevision":"r1"}},"requiresAuthentication":true,"requiresApproval":false},{"actionId":"auth-setup","label":"Read the existing agent authentication setup","operationId":"existing_auth_setup","method":"GET","relativePath":"/mcp/setup","origin":"api","parameters":{},"requiresAuthentication":false,"requiresApproval":false},{"actionId":"browse:stack:framework-fastapi","label":"Browse FastAPI","operationId":"browse_node","method":"GET","relativePath":"/v1/catalog/nodes/stack%3Aframework-fastapi","origin":"api","parameters":{"nodeId":"stack:framework-fastapi"},"requiresAuthentication":false,"requiresApproval":false},{"actionId":"browse:intent:connect-app-to-storage","label":"Browse Connect app to storage","operationId":"browse_node","method":"GET","relativePath":"/v1/catalog/nodes/intent%3Aconnect-app-to-storage","origin":"api","parameters":{"nodeId":"intent:connect-app-to-storage"},"requiresAuthentication":false,"requiresApproval":false},{"actionId":"browse:pattern:browser-file-uploads","label":"Browse Browser file uploads","operationId":"browse_node","method":"GET","relativePath":"/v1/catalog/nodes/pattern%3Abrowser-file-uploads","origin":"api","parameters":{"nodeId":"pattern:browser-file-uploads"},"requiresAuthentication":false,"requiresApproval":false}]}