All Projects β†’ amancevice β†’ terraform-aws-serverless-pypi

amancevice / terraform-aws-serverless-pypi

Licence: MIT License
Serverless PyPI backed by S3

Programming Languages

python
139335 projects - #7 most used programming language
HCL
1544 projects
Makefile
30231 projects

Projects that are alternatives of or similar to terraform-aws-serverless-pypi

mongo
Light-weight utilities and declarative schema (mutable mapping) to augment, not replace the Python MongoDB driver.
Stars: ✭ 18 (-45.45%)
Mutual labels:  pypi
datagoose
πŸ” Easy to use, fast, lightweight, secure, JSON based database for Python!
Stars: ✭ 13 (-60.61%)
Mutual labels:  pypi
verneuil
Verneuil is a VFS extension for SQLite that asynchronously replicates databases to S3-compatible blob stores.
Stars: ✭ 169 (+412.12%)
Mutual labels:  s3
ahocorapy
Pure python Aho-Corasick library.
Stars: ✭ 163 (+393.94%)
Mutual labels:  pypi
django-archive
Management command for creating compressed archives of Django projects, including database tables and uploaded media.
Stars: ✭ 27 (-18.18%)
Mutual labels:  pypi
arpwitch
A modern arpwatch replacement with JSON formatted outputs and easy options to exec commands when network changes are observed.
Stars: ✭ 20 (-39.39%)
Mutual labels:  pypi
apt-golang-s3
An s3 transport method for the apt package management system
Stars: ✭ 33 (+0%)
Mutual labels:  s3
terraform-aws-s3-bucket
A Terraform module to create a Simple Storage Service (S3) Bucket on Amazon Web Services (AWS). https://aws.amazon.com/s3/
Stars: ✭ 47 (+42.42%)
Mutual labels:  s3
radio
Redundant Array of Distributed Independent Objectstores in short RADIO performs synchronous mirroring, erasure coding across multiple object stores
Stars: ✭ 25 (-24.24%)
Mutual labels:  s3
s3manager
A Web GUI for your S3 buckets
Stars: ✭ 39 (+18.18%)
Mutual labels:  s3
HypixelIO
A Modern Efficient and Easy way of interacting with the Hypixel API!
Stars: ✭ 16 (-51.52%)
Mutual labels:  pypi
s3-sync
Migrating S3 Buckets Across AWSΒ Accounts
Stars: ✭ 55 (+66.67%)
Mutual labels:  s3
liquid
Abstract file storage component made for Vapor 4.
Stars: ✭ 29 (-12.12%)
Mutual labels:  s3
s3-lambda-transcribe-audio-to-text-s3
Transcribe your audio to text with this serverless component
Stars: ✭ 84 (+154.55%)
Mutual labels:  s3
laravel-s3-tools
This Laravel package contains additional functionality not currently in Laravel for interfacing with Amazon's S3 service (including managing versioned objects).
Stars: ✭ 31 (-6.06%)
Mutual labels:  s3
imgur-scraper
Retrieve years of imgur.com's data without any authentication.
Stars: ✭ 26 (-21.21%)
Mutual labels:  pypi
allalgorithms-python
The All β–²lgorithms Python Library.
Stars: ✭ 31 (-6.06%)
Mutual labels:  pypi
django-docker-s3
Django + S3
Stars: ✭ 43 (+30.3%)
Mutual labels:  s3
docker base images
Vlad's Base Images for Docker
Stars: ✭ 61 (+84.85%)
Mutual labels:  s3
docker-s3fs
S3FS Docker image
Stars: ✭ 18 (-45.45%)
Mutual labels:  s3

Serverless PyPI

terraform py.test coverage maintainability

S3-backed serverless PyPI.

Requests to your PyPI server will be proxied through a Lambda function that pulls content from an S3 bucket and responds with the same HTML content that you might find in a conventional PyPI server.

Requests to the base path (eg, /simple/) will respond with the contents of an index.html file at the root of your S3 bucket.

Requests to the package index (eg, /simple/fizz/) will dynamically generate an HTML file based on the contents of keys under that namespace (eg, s3://your-bucket/fizz/). URLs for package downloads are presigned S3 URLs with a default lifespan of 15 minutes.

Package uploads/removals on S3 will trigger a Lambda function that reindexes the bucket and generates a new index.html at the root. This is done to save time when querying the base path when your bucket contains a multitude of packages.

Serverless PyPI

Usage

As of v3 users are expected to bring-your-own HTTP (v2) API instead of providing one inside the module. This gives users greater flexibility in choosing how their API is set up.

The most simplistic setup is as follows:

resource "aws_apigatewayv2_api" "pypi" {
  name          = "pypi"
  protocol_type = "HTTP"
}

module "serverless_pypi" {
  source  = "amancevice/serverless-pypi/aws"
  version = "~> 4.1"

  api_id                       = aws_apigatewayv2_api.pypi.id
  api_execution_arn            = aws_apigatewayv2_api.pypi.execution_arn
  iam_role_name                = "serverless-pypi-role"
  lambda_api_function_name     = "serverless-pypi-api"
  lambda_reindex_function_name = "serverless-pypi-reindex"
  s3_bucket_name               = "serverless-pypi"
  sns_topic_name               = "serverless-pypi"

  # etc …
}

S3 Bucket Organization

This tool is highly opinionated about how your S3 bucket is organized. Your root key space should only contain the auto-generated index.html and "directories" of your PyPI packages.

Packages should exist one level deep in the bucket where the prefix is the name of the project.

Example:

s3://your-bucket/
β”œβ”€β”€ index.html
β”œβ”€β”€ my-cool-package/
β”‚   β”œβ”€β”€ my-cool-package-0.1.2.tar.gz
β”‚   β”œβ”€β”€ my-cool-package-1.2.3.tar.gz
β”‚   └── my-cool-package-2.3.4.tar.gz
└── my-other-package/
    β”œβ”€β”€ my-other-package-0.1.2.tar.gz
    β”œβ”€β”€ my-other-package-1.2.3.tar.gz
    └── my-other-package-2.3.4.tar.gz

Fallback PyPI Index

You can configure your PyPI index to fall back to a different PyPI in the event that a package is not found in your bucket.

Without configuring a fallback index URL the following pip install command will surely fail (assuming you don't have boto3 and all its dependencies in your S3 bucket):

pip install boto3 --index-url https://my.private.pypi/simple/

Instead, if you configure a fallback index URL in the terraform module, then requests for a pip that isn't found in the bucket will be re-routed to the fallback.

module "serverless_pypi" {
  source  = "amancevice/serverless-pypi/aws"
  version = "~> 4.1"

  lambda_api_fallback_index_url = "https://pypi.org/simple/"

  # etc …
}

Auth

Please note that this tool provides NO authentication layer for your PyPI index out of the box. This is difficult to implement because pip is currently not very forgiving with any kind of auth pattern outside Basic Auth.

Cognito Basic Auth

I have provided a very simple authentication implementation using AWS Cognito and API Gateway authorizers.

Add a Cognito-backed Basic authentication layer to your serverless PyPI with the serverless-pypi-cognito module:

module "serverless_pypi" {
  source  = "amancevice/serverless-pypi/aws"
  version = "~> 4.1"

  api_authorization_type = "CUSTOM"
  api_authorizer_id      = module.serverless_pypi_cognito.api_authorizer.id

  # …
}

module "serverless_pypi_cognito" {
  source  = "amancevice/serverless-pypi-cognito/aws"
  version = "~> 2.0"

  api_id                 = aws_apigatewayv2_api.pypi.id
  cognito_user_pool_name = "serverless-pypi-cognito-pool"
  iam_role_name          = module.serverless_pypi.iam_role.name
  lambda_function_name   = "serverless-pypi-authorizer"
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].