lgw

Configure an AWS Gateway in front of a Lambda function.


Keywords
aws-api-gateway, aws-lambda, python3, serverless, serverless-framework
License
Apache-2.0
Install
pip install lgw==1.0.0.post1

Documentation

PyPi License PyPi

Lambda Gateway

Configure an AWS Gateway in front of a Lambda function.

Usage

Lambda Gateway.

Usage:
  lgw gw-deploy [--verbose] [--config-file=<cfg>]
  lgw gw-undeploy [--verbose] [--config-file=<cfg>]
  lgw domain-add [--verbose] [--config-file=<cfg>]
  lgw domain-remove [--verbose] [--config-file=<cfg>]
  lgw lambda-deploy [--verbose] [--config-file=<cfg>] [--lambda-file=<zip>]
  lgw lambda-invoke [--verbose] --lambda-name=<name> [--payload=<json>]
  lgw lambda-delete [--verbose] --lambda-name=<name>
  lgw lambda-archive [--verbose] [--config-file=<cfg>]

Options:
  -h --help             Show this screen.
  --version             Show version.
  --verbose             Enable DEBUG-level logging.
  --config-file=<cfg>   Override defaults with these settings.
  --lambda-file=<zip>   Path to zip file with executable lambda code.
  --lambda-name=<name>  Name of the lambda to invoke or delete.
  --payload=<json>      Path to a file of type json with data to send with the lambda invocation.

Configuration Parameters

Configuration params are read in the following order, with the first read of it overriding subsequent configs:

  1. Read from environment.
  2. Read from .env file in current folder.
  3. Read from flat file named via --config-file CLI param.
  4. Read from lgw.settings.defaults()

Defaults are configured in lgw.settings.

Related Task(s) Key Description Default
  • All
AWS_REGION AWS region. us-east-1
  • gw-deploy
  • gw-undeploy
  • domain-add
  • domain-remove
AWS_API_NAME Name for the created API gateway. N/A
  • gw-deploy
AWS_API_DESCRIPTION Description of the created API gateway. N/A
  • gw-deploy
AWS_API_RESOURCE_PATH Resource path for the API. By default it's a greedy path to proxy all requests. {proxy+}
  • gw-deploy
AWS_API_DEPLOY_STAGE Name for the stage that the API gets deployed to. E.g. "production" N/A
  • gw-deploy
AWS_API_BINARY_TYPES Listing of binary media types to configure the gateway as handling. Example: image/jpeg,image/png N/A
  • gw-deploy
AWS_API_RESPONSE_MODELS Response content-type: model mapping of the response body. Typically used for mapping binary content-types. For binary types specify: image/*=Empty application/json=Empty
  • gw-deploy
AWS_API_LAMBDA_INTEGRATION_ROLE ARN of a role that grants permission to the API gateway to invoke a lambda. Should have AmazonAPIGatewayPushToCloudWatchLogs and AWSLambdaRole managed roles as permissions, and apigateway.amazonaws.com as a trusted entity. N/A
  • domain-add
AWS_API_DOMAIN_NAME A domain name configured in Route 53 that the API gateway can be mapped to. N/A
  • domain-add
AWS_API_BASE_PATH Base path mapping to connect the domain name's CF distribution to the gateway. (none)
  • domain-add
AWS_API_DOMAIN_WAIT_UNTIL_AVAILABLE Waits until the custom domain name has been created. true, set to undefined to disable.
  • domain-add
AWS_ACM_CERTIFICATE_ARN ARN of an HTTPS certificate to use for securing API requests. N/A
  • gw-deploy
  • lambda-deploy
AWS_LAMBDA_NAME Name for the created Lambda. N/A
  • lambda-deploy
AWS_LAMBDA_DESCRIPTION Description for the created Lambda N/A
  • lambda-deploy
AWS_LAMBDA_HANDLER Name of the handler function. e.g. "module.function" N/A
  • lambda-deploy
AWS_LAMBDA_RUNTIME Lambda runtime environment. N/A
  • lambda-deploy
AWS_LAMBDA_CONNECTION_TIMEOUT Connection timeout in seconds. 30
  • lambda-deploy
AWS_LAMBDA_MEMORY_SIZE Amount of memory to allocate to the Lambda. 3000
  • lambda-deploy
AWS_LAMBDA_ARCHIVE_BUCKET S3 bucket to store lambda if zip file exceeds maximum upload size. N/A
  • lambda-deploy
AWS_LAMBDA_ARCHIVE_KEY Key of the lambda archive in the configured bucket. N/A
  • lambda-deploy
AWS_LAMBDA_EXECUTION_ROLE_ARN ARN of a role with permissions to execute the Lambda. Should have AWSXrayWriteOnlyAccess and AWSLambdaBasicExecutionRole managed roles as permissions, and lambda.amazonaws.com as a trusted entity. N/A
  • lambda-deploy
AWS_LAMBDA_VPC_SUBNETS List of subnets that the Lambda should run in. Format: "subnetA,subnetB,subnetC,... N/A
  • lambda-deploy
AWS_LAMBDA_VPC_SECURITY_GROUPS List of security groups that control the Lambda's access. Format: "secgrpA,secgrpB,secgrpC,..." N/A
  • lambda-deploy
AWS_LAMBDA_ENVIRONMENT Variables to inject into the Lambda's environment. Format: "varA=valA;varB=valB;..." N/A
  • lambda-deploy
AWS_LAMBDA_TAGS List of tags to categorize this Lambda. Format: "tagA=valA;tagB=valB;..." N/A
  • lambda-archive
AWS_LAMBDA_ARCHIVE_CONTEXT_DIR Root directory of the project that will provide files to be copied into the Docker image. If the directory ends with a trailing slash, then the root of the context will be the contents of the directory; otherwise the leaf directory will be at the root of the context. .
  • lambda-archive
AWS_LAMBDA_ARCHIVE_BUNDLE_DIR Destination directory to write Lambda archive zipfile. ./build
  • lambda-archive
AWS_LAMBDA_ARCHIVE_BUNDLE_NAME Filename of Lambda archive zipfile. lambda-bundle.zip
  • lambda-archive
AWS_LAMBDA_ARCHIVE_ADDL_FILES List of 2-tuples of files to copy into the context directory from the local computer. Format: "srcA,desA;srcB,desB;srcC,desC;..." N/A
  • lambda-archive
AWS_LAMBDA_ARCHIVE_ADDL_PACKAGES List of yum packages to install in the Docker image. Format: "packageA,packageB,packageC,..." Default installed by this script:
  • gcc
  • openssl-devel
  • bzip2-devel
  • libffi-devel
  • python37-pip

Releasing

git flow release start x.y.z
# bump version
vi pyproject.toml lgw/version.py
git add pyproject.toml lgw/version.py
git commit -m 'bump version'
dephell deps convert
poetry publish --build
git flow release finish x.y.z