Skip to main content

Helpers to deploy lambda functions in an immutable way

Project description

lambda_freezer

Goals:

  • Make it easy to deploy one or many services under the same Amazon API Gateway.
  • Make it easy to deploy a stage in an immutable way.

Deploy a specific stage

The main aim of this module is to help your Amazon API Gateway work in such a way that each stage is immutable. This is achieved by using the versioning and aliasing features of Lambda function, as well as stage variables. The gist is this:

  • When deploying a stage, each underlying Lambda function is frozen to a specific version.
  • When calling the resouces for that particular stage, the "frozen" versioning of Lambda functions will be called (indirectly via an alias).

For more information of how that is achieved "manually" in more details: https://aws.amazon.com/blogs/compute/using-api-gateway-stage-variables-to-manage-lambda-functions/

Python 3.6.9 (default, Nov  7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lambda_freezer
>>> REST_API_ID = "r5ltm5nqr6"
>>> REGION = "us-east-1"
>>> APILIB_DEFAULT_ALIAS_NAME = "uat"
>>> DOMAIN_NAME = "api-library.puno.io" # this guy is optional
>>> deploy(REST_API_ID, REGION, "0.0.1", "some description", APILIB_DEFAULT_ALIAS_NAME, DOMAIN_NAME)

Flow (super opinionated)

  • use serverless framework and configure like something below.
 - provider:
      name: aws
      runtime: python3.6
      stage: latest # IMPORTANT - this need to match -> APILIB_DEFAULT_ALIAS_NAME
      versionFunctions: false # versioning would be done only upon deploying/"freezing" to a stage
      apiGateway: # make sure you point to a common api gateway
        restApiId:
          'Fn::ImportValue': 'OUTPUT-ApiGatewayRestApiId-REPLACE-WITH-OWN'
        restApiRootResourceId:
          'Fn::ImportValue': 'OUTPUT-ApiGatewayRestApiRootResourceId-REPLACE-WITH-OWN'
  • To push your functions and make sure the api gateway integration gets changed. (We want that every function integrations' are such that the api gateway can only call a specific version of any lambda functions via an alias, using a stage variable).
serverless deploy
Python 3.6.9 (default, Nov  7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lambda_freezer
>>> REST_API_ID = "r5ltm5nqr6"
>>> REGION = "us-east-1"
>>> APILIB_DEFAULT_ALIAS_NAME = "uat"
>>> DOMAIN_NAME = "api-library.puno.io" # this guy is optional
>>> run_after_default_deployment(REST_API_ID, REGION, APILIB_DEFAULT_ALIAS_NAME, DOMAIN_NAME)
  • When you like a specific version of your functions, just "freeze" them using the deploy cmd described above.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lambda-freezer-0.0.9.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lambda_freezer-0.0.9-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file lambda-freezer-0.0.9.tar.gz.

File metadata

  • Download URL: lambda-freezer-0.0.9.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for lambda-freezer-0.0.9.tar.gz
Algorithm Hash digest
SHA256 229be8bda2161b44cea1f8f0f69e26039844bf232e0284fe307f4a6020c55cd7
MD5 f1daf4f49126a53e64462e9db029ed9f
BLAKE2b-256 396a1dc3b0e9c40481c3389192c0a742463ac41699cc90ff6dfdafce436a40a2

See more details on using hashes here.

File details

Details for the file lambda_freezer-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: lambda_freezer-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for lambda_freezer-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 01522a9aa50c5afb98fc01c40d7e733d34a4728cb631b6110e80291874be8623
MD5 2619f7678f6bf82a2ca866b939e88cb2
BLAKE2b-256 3df31e06942f1de53676856d191465532bf64cab272ef28b3b4f4e5922035513

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page