testcontainers-aws is a set of AWS containers modules that can be used to create AWS containers.
- class AWSLambdaContainer(image: str | DockerImage, port: int = 8080)¶
AWS Lambda container that is based on a custom image.
Example
>>> from testcontainers.aws import AWSLambdaContainer >>> from testcontainers.core.waiting_utils import wait_for_logs >>> from testcontainers.core.image import DockerImage >>> with DockerImage(path="./modules/aws/tests/lambda_sample", tag="test-lambda:latest") as image: ... with AWSLambdaContainer(image=image, port=8080) as func: ... response = func.send_request(data={'payload': 'some data'}) ... assert response.status_code == 200 ... assert "Hello from AWS Lambda using Python" in response.json() ... delay = wait_for_logs(func, "START RequestId:")
- Parameters:
image – Docker image to be used for the container.
port – Port to be exposed on the container (default: 8080).
The following environment variables are used by the AWS Lambda container:
Env Variable |
Default |
Notes |
|---|---|---|
|
|
Fetched from os environment |
|
|
Fetched from os environment |
|
|
Fetched from os environment |
Each one of the environment variables is expected to be set in the host machine where the test is running.
Make sure you are using an image based on public.ecr.aws/lambda/python
Please checkout https://docs.aws.amazon.com/lambda/latest/dg/python-image.html for more information on how to run AWS Lambda functions locally.