elastic pypi

serverless pypi on aws

Instructions

Configuration

By CLI


sls deploy --stage production --bucket my-elasticpypi --password horse-battery-staple

See the serverless.yml for all options

By serverless.yml

service: elasticpypi

provider:
  name: aws
  runtime: python3.9
  memorySize: 128
  stage: dev
  # profile: "some-local-aws-config-profile"
  # region: us-east-1

  environment:
    SERVICE: ${self:service}          # See above. Defaults to elasticpypi
    STAGE: "/${self:provider.stage}"  # See above. Defaults to dev
    BUCKET: "elasticpypi"             # CHANGE ME
    TABLE: "elasticpypi"              # You can change me if you want, but do you?
    USERNAME: "elasticpypi"           # You can change me if you want, but do you?
    PASSWORD: "something-secretive"   # CHANGE ME
    OVERWRITE: false                  # Allow uploads to overwrite already existing packages

Install dependencies

npm/yarn and pip are required to install the necessary packages to deploy.

yarn or npm install

Deploy

sls deploy

Notes

The deploy will automatically fetch the python requirements.

Using

Based on the output of the deploy command or via the AWS console add the url to your pip conf.

The url should be something like https://blah.execute-api.region.amazonaws.com/dev/simple.

Make sure you add a trailing slash as required in the PEP.

Make sure you add your basic authentication credentials to your url.

Throttling

AWS resources maybe throttled. As such, if you are intending to dump a bunch of packages into the S3 bucket check your service and account limits. Additionally, changing the read and write capacity of dynamodb may help. It is currently set to the lowest possible unit (1).