Skip to content

Instantly share code, notes, and snippets.

@fliepeltje
Created July 25, 2024 10:28
Show Gist options
  • Save fliepeltje/5be7d0a6f1ada057b1eb3aa357cd4961 to your computer and use it in GitHub Desktop.
Save fliepeltje/5be7d0a6f1ada057b1eb3aa357cd4961 to your computer and use it in GitHub Desktop.
FastAPI with boto3 on Fly.io
import os
import boto3
from fastapi import FastAPI
S3_URL = os.getenv("AWS_ENDPOINT_URL_S3")
svc = boto3.client('s3', endpoint_url=S3_URL)
app = FastAPI()
@app.get("/")
async def read_root():
buckets = svc.list_buckets()
return {"buckets": [bucket["Name"] for bucket in buckets["Buckets"]]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment