Hi there, I am using `aws.lambda_.Function` to cre...
# aws
s
Hi there, I am using
aws.lambda_.Function
to create a AWS lambda with Python (the lambda running under FastAPI+Mangum), but I’m a bit confused on how to pack the python dependencies for the lambda. So far I’ve been doing the following:
Copy code
import pulumi
import pulumi_aws as aws

my_lambda_lambda_func = aws.lambda_.Function(
    "my-lambda-name",
    name="my-lambda-name",
    role=iam_role_for_lambda.arn,
    runtime="python3.9",
    handler="main.handler",
    package_type="zip",
    code=pulumi.AssetArchive(
        {".": pulumi.FileArchive("./lambdas/my_lambda")}
    ),
    environment=aws.lambda_.FunctionEnvironmentArgs(
        variables={
            "VAR": "my-env-var",
        },
    ),
)
The lamba iteself is organized that way:
Copy code
/lambdas/my_lambda/
    main.py
    pyproject.toml
    requirements.txt
How can I pack the Python dependencies? I would prefer using a zip instead of a Docker container as it is part of a big Pulumi stack. If I esport the dependencies toi a
/lib
folder with something like
pip install -t lib -r requirements.txt
, will it be taken into account? Should they be exported at the root of the lambda instead? Can we pass the libs/dependencies folder path to the Pulumi
lambda_.Function
object?