Skip to content

vrbrito/fastapi-url-service

Repository files navigation

FastAPI URL Service

Create a service deployed on AWS Lambda that provides access to private S3 bucket files through pre-signed urls tracking usage based on token authentication.

Stack

  • Application core: Python + FastAPI
  • Package manager: Poetry
  • Testing: Pytest + Moto
  • Infrastructure management: Terraform
  • Cloud services: AWS Lambda + DynamoDB + S3

Requirements

Core

  • Setup package manager
  • Install FastAPI
  • Create dummy endpoint
  • Setup S3 integration
  • Create endpoint to list files
  • Create endpoint to retrieve pre-signed url for a specific file
  • Setup linting
  • Setup testing
  • Improve testing to use factory boy
  • Improve testing by using moto to mock AWS services
  • Setup persistence layer (DynamoDB?)
  • Create endpoint to add new user
  • Setup token auth to API
  • Create usage measurements based on token auth

Infra

  • Setup base terraform for managing resources
  • Setup S3 resource (make it fully private to avoid public access)
  • Setup DynamoDB resource
  • Setup FastAPI deploy to AWS Lambda
  • Adjust role to include S3 and DynamoDB permissions
  • Setup CI/CD pipeline
  • Setup pre-commit hooks
  • Integrate project with localstack for easy local testing

Architecture

  • Improve code architecture by including service/repo layers

Improvements

  • Avoid local env from using real resources
  • Include .env variables for deployed env

Bugs

  • Redirect loop happening on the deployed version of the app

Database

For this project, a single-table approach was chosen to be used on DynamoDB, for this, listing the use-cases is very important.

Use cases

  • Check if user token exists (read)
  • Register new user (write)
    • Email must be unique across all users
  • Register usage for each new request (write)
  • Fetch usage based on token (read)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published