Skip to main content

The CDK Construct Library for AWS Lambda in Python

Project description

Amazon Lambda Python Library

---

cdk-constructs: Experimental

The APIs of higher level constructs in this module are experimental and under active development. They are subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model and breaking changes will be announced in the release notes. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.


This library provides constructs for Python Lambda functions.

To use this module, you will need to have Docker installed.

Python Function

Define a PythonFunction:

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_lambda as lambda_
from aws_cdk.aws_lambda_python import PythonFunction

PythonFunction(self, "MyFunction",
    entry="/path/to/my/function", # required
    index="my_index.py", # optional, defaults to 'index.py'
    handler="my_exported_func", # optional, defaults to 'handler'
    runtime=lambda_.Runtime.PYTHON_3_6
)

All other properties of lambda.Function are supported, see also the AWS Lambda construct library.

Module Dependencies

If requirements.txt or Pipfile exists at the entry path, the construct will handle installing all required modules in a Lambda compatible Docker container according to the runtime.

Lambda with a requirements.txt

.
├── lambda_function.py # exports a function named 'handler'
├── requirements.txt # has to be present at the entry path

Lambda with a Pipfile

.
├── lambda_function.py # exports a function named 'handler'
├── Pipfile # has to be present at the entry path
├── Pipfile.lock # your lock file

Lambda Layer Support

You may create a python-based lambda layer with PythonLayerVersion. If PythonLayerVersion detects a requirements.txt or Pipfile at the entry path, then PythonLayerVersion will include the dependencies inline with your code in the layer.

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
lambda_.PythonFunction(self, "MyFunction",
    entry="/path/to/my/function",
    layers=[
        lambda_.PythonLayerVersion(self, "MyLayer",
            entry="/path/to/my/layer"
        )
    ]
)

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

aws-cdk.aws-lambda-python-1.72.0.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file aws-cdk.aws-lambda-python-1.72.0.tar.gz.

File metadata

  • Download URL: aws-cdk.aws-lambda-python-1.72.0.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.5

File hashes

Hashes for aws-cdk.aws-lambda-python-1.72.0.tar.gz
Algorithm Hash digest
SHA256 34290f4d7a3ebc3deda06a1c1f4e5a5dcb2368359f944206e739f776bf350ee8
MD5 6b2c771195c58fd4bc8ac9bd3aa51281
BLAKE2b-256 69b6d9b15c0885c10a1680cd6785896d87495467408e386c7f10aaf1f6f17f80

See more details on using hashes here.

File details

Details for the file aws_cdk.aws_lambda_python-1.72.0-py3-none-any.whl.

File metadata

  • Download URL: aws_cdk.aws_lambda_python-1.72.0-py3-none-any.whl
  • Upload date:
  • Size: 28.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.5

File hashes

Hashes for aws_cdk.aws_lambda_python-1.72.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5e339a82a857a9f183b64e2f766f016da8c31e1efa6141b2af0dce9a0dd5c71
MD5 13f6d21fd6658bf681a962d26a24ba31
BLAKE2b-256 1db4470fdd3c86a5883635cffd14cbc844510b619da32ab6104923ec787af68e

See more details on using hashes here.

Supported by

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