{ "author": { "name": "Amazon Web Services", "organization": true, "roles": [ "author" ], "url": "https://aws.amazon.com" }, "dependencies": { "@aws-cdk/aws-ec2": "1.204.0", "@aws-cdk/aws-lambda": "1.204.0", "@aws-cdk/core": "1.204.0", "constructs": "^3.3.69" }, "dependencyClosure": { "@aws-cdk/assets": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.Assets", "packageId": "Amazon.CDK.Assets" }, "java": { "maven": { "artifactId": "cdk-assets", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.assets" }, "js": { "npm": "@aws-cdk/assets" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.assets", "module": "aws_cdk.assets" } } }, "@aws-cdk/aws-applicationautoscaling": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.ApplicationAutoScaling", "packageId": "Amazon.CDK.AWS.ApplicationAutoScaling" }, "java": { "maven": { "artifactId": "applicationautoscaling", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.applicationautoscaling" }, "js": { "npm": "@aws-cdk/aws-applicationautoscaling" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-applicationautoscaling", "module": "aws_cdk.aws_applicationautoscaling" } } }, "@aws-cdk/aws-autoscaling-common": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.AutoScaling.Common", "packageId": "Amazon.CDK.AWS.AutoScaling.Common" }, "java": { "maven": { "artifactId": "autoscaling-common", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.autoscaling.common" }, "js": { "npm": "@aws-cdk/aws-autoscaling-common" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-autoscaling-common", "module": "aws_cdk.aws_autoscaling_common" } } }, "@aws-cdk/aws-cloudwatch": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.CloudWatch", "packageId": "Amazon.CDK.AWS.CloudWatch" }, "java": { "maven": { "artifactId": "cloudwatch", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.cloudwatch" }, "js": { "npm": "@aws-cdk/aws-cloudwatch" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-cloudwatch", "module": "aws_cdk.aws_cloudwatch" } } }, "@aws-cdk/aws-codeguruprofiler": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.CodeGuruProfiler", "packageId": "Amazon.CDK.AWS.CodeGuruProfiler" }, "java": { "maven": { "artifactId": "codeguruprofiler", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.codeguruprofiler" }, "js": { "npm": "@aws-cdk/aws-codeguruprofiler" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-codeguruprofiler", "module": "aws_cdk.aws_codeguruprofiler" } } }, "@aws-cdk/aws-codestarnotifications": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.CodeStarNotifications", "packageId": "Amazon.CDK.AWS.CodeStarNotifications" }, "java": { "maven": { "artifactId": "codestarnotifications", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.codestarnotifications" }, "js": { "npm": "@aws-cdk/aws-codestarnotifications" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-codestarnotifications", "module": "aws_cdk.aws_codestarnotifications" } } }, "@aws-cdk/aws-ec2": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.EC2", "packageId": "Amazon.CDK.AWS.EC2" }, "java": { "maven": { "artifactId": "ec2", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.ec2" }, "js": { "npm": "@aws-cdk/aws-ec2" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-ec2", "module": "aws_cdk.aws_ec2" } } }, "@aws-cdk/aws-ecr": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.ECR", "packageId": "Amazon.CDK.AWS.ECR" }, "java": { "maven": { "artifactId": "ecr", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.ecr" }, "js": { "npm": "@aws-cdk/aws-ecr" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-ecr", "module": "aws_cdk.aws_ecr" } } }, "@aws-cdk/aws-ecr-assets": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.Ecr.Assets", "packageId": "Amazon.CDK.ECR.Assets" }, "java": { "maven": { "artifactId": "ecr-assets", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.ecr.assets" }, "js": { "npm": "@aws-cdk/aws-ecr-assets" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-ecr-assets", "module": "aws_cdk.aws_ecr_assets" } } }, "@aws-cdk/aws-efs": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.EFS", "packageId": "Amazon.CDK.AWS.EFS" }, "java": { "maven": { "artifactId": "efs", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.efs" }, "js": { "npm": "@aws-cdk/aws-efs" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-efs", "module": "aws_cdk.aws_efs" } } }, "@aws-cdk/aws-events": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.Events", "packageId": "Amazon.CDK.AWS.Events" }, "java": { "maven": { "artifactId": "events", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.events" }, "js": { "npm": "@aws-cdk/aws-events" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-events", "module": "aws_cdk.aws_events" } } }, "@aws-cdk/aws-iam": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.IAM", "packageId": "Amazon.CDK.AWS.IAM" }, "java": { "maven": { "artifactId": "iam", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.iam" }, "js": { "npm": "@aws-cdk/aws-iam" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-iam", "module": "aws_cdk.aws_iam" } } }, "@aws-cdk/aws-kms": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.KMS", "packageId": "Amazon.CDK.AWS.KMS" }, "java": { "maven": { "artifactId": "kms", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.kms" }, "js": { "npm": "@aws-cdk/aws-kms" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-kms", "module": "aws_cdk.aws_kms" } } }, "@aws-cdk/aws-lambda": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.Lambda", "packageId": "Amazon.CDK.AWS.Lambda" }, "java": { "maven": { "artifactId": "lambda", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.lambda" }, "js": { "npm": "@aws-cdk/aws-lambda" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-lambda", "module": "aws_cdk.aws_lambda" } } }, "@aws-cdk/aws-logs": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.Logs", "packageId": "Amazon.CDK.AWS.Logs" }, "java": { "maven": { "artifactId": "logs", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.logs" }, "js": { "npm": "@aws-cdk/aws-logs" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-logs", "module": "aws_cdk.aws_logs" } } }, "@aws-cdk/aws-s3": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.S3", "packageId": "Amazon.CDK.AWS.S3" }, "java": { "maven": { "artifactId": "s3", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.s3" }, "js": { "npm": "@aws-cdk/aws-s3" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-s3", "module": "aws_cdk.aws_s3" } } }, "@aws-cdk/aws-s3-assets": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.S3.Assets", "packageId": "Amazon.CDK.AWS.S3.Assets" }, "java": { "maven": { "artifactId": "s3-assets", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.s3.assets" }, "js": { "npm": "@aws-cdk/aws-s3-assets" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-s3-assets", "module": "aws_cdk.aws_s3_assets" } } }, "@aws-cdk/aws-signer": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.Signer", "packageId": "Amazon.CDK.AWS.Signer" }, "java": { "maven": { "artifactId": "signer", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.signer" }, "js": { "npm": "@aws-cdk/aws-signer" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-signer", "module": "aws_cdk.aws_signer" } } }, "@aws-cdk/aws-sns": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.SNS", "packageId": "Amazon.CDK.AWS.SNS" }, "java": { "maven": { "artifactId": "sns", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.sns" }, "js": { "npm": "@aws-cdk/aws-sns" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-sns", "module": "aws_cdk.aws_sns" } } }, "@aws-cdk/aws-sqs": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.SQS", "packageId": "Amazon.CDK.AWS.SQS" }, "java": { "maven": { "artifactId": "sqs", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.sqs" }, "js": { "npm": "@aws-cdk/aws-sqs" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-sqs", "module": "aws_cdk.aws_sqs" } } }, "@aws-cdk/aws-ssm": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.SSM", "packageId": "Amazon.CDK.AWS.SSM" }, "java": { "maven": { "artifactId": "ssm", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.ssm" }, "js": { "npm": "@aws-cdk/aws-ssm" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-ssm", "module": "aws_cdk.aws_ssm" } } }, "@aws-cdk/cloud-assembly-schema": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.CloudAssembly.Schema", "packageId": "Amazon.CDK.CloudAssembly.Schema" }, "java": { "maven": { "artifactId": "cdk-cloud-assembly-schema", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.cloudassembly.schema" }, "js": { "npm": "@aws-cdk/cloud-assembly-schema" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.cloud-assembly-schema", "module": "aws_cdk.cloud_assembly_schema" } } }, "@aws-cdk/core": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK", "packageId": "Amazon.CDK" }, "java": { "maven": { "artifactId": "core", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.core" }, "js": { "npm": "@aws-cdk/core" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.core", "module": "aws_cdk.core" } } }, "@aws-cdk/cx-api": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.CXAPI", "packageId": "Amazon.CDK.CXAPI" }, "java": { "maven": { "artifactId": "cdk-cx-api", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.cxapi" }, "js": { "npm": "@aws-cdk/cx-api" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.cx-api", "module": "aws_cdk.cx_api" } } }, "@aws-cdk/region-info": { "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.RegionInfo", "packageId": "Amazon.CDK.RegionInfo" }, "java": { "maven": { "artifactId": "cdk-region-info", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.regioninfo" }, "js": { "npm": "@aws-cdk/region-info" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.region-info", "module": "aws_cdk.region_info" } } }, "constructs": { "targets": { "dotnet": { "namespace": "Constructs", "packageId": "Constructs" }, "go": { "moduleName": "github.com/aws/constructs-go" }, "java": { "maven": { "artifactId": "constructs", "groupId": "software.constructs" }, "package": "software.constructs" }, "js": { "npm": "constructs" }, "python": { "distName": "constructs", "module": "constructs" } } } }, "description": "The CDK Construct Library for AWS Lambda in Python", "docs": { "deprecated": "AWS CDK v1 has reached End-of-Support on 2023-06-01.\nThis package is no longer being updated, and users should migrate to AWS CDK v2.\n\nFor more information on how to migrate, see https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html", "stability": "experimental" }, "homepage": "https://github.com/aws/aws-cdk", "jsiiVersion": "1.84.0 (build 5404dcf)", "keywords": [ "aws", "cdk", "constructs", "lambda" ], "license": "Apache-2.0", "metadata": { "jsii": { "compiledWithDeprecationWarnings": true, "pacmak": { "hasDefaultInterfaces": true }, "rosetta": { "strict": true } } }, "name": "@aws-cdk/aws-lambda-python", "readme": { "markdown": "# Amazon Lambda Python Library\n\n\n---\n\n![End-of-Support](https://img.shields.io/badge/End--of--Support-critical.svg?style=for-the-badge)\n\n> AWS CDK v1 has reached End-of-Support on 2023-06-01.\n> This package is no longer being updated, and users should migrate to AWS CDK v2.\n>\n> For more information on how to migrate, see the [_Migrating to AWS CDK v2_ guide][doc].\n>\n> [doc]: https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html\n\n---\n\n\n\n\nThis library provides constructs for Python Lambda functions.\n\nTo use this module, you will need to have Docker installed.\n\n## Python Function\n\nDefine a `PythonFunction`:\n\n```ts\nnew lambda.PythonFunction(this, 'MyFunction', {\n entry: '/path/to/my/function', // required\n runtime: Runtime.PYTHON_3_8, // required\n index: 'my_index.py', // optional, defaults to 'index.py'\n handler: 'my_exported_func', // optional, defaults to 'handler'\n});\n```\n\nAll other properties of `lambda.Function` are supported, see also the [AWS Lambda construct library](https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/aws-lambda).\n\n## Python Layer\n\nYou may create a python-based lambda layer with `PythonLayerVersion`. If `PythonLayerVersion` detects a `requirements.txt`\nor `Pipfile` or `poetry.lock` with the associated `pyproject.toml` at the entry path, then `PythonLayerVersion` will include the dependencies inline with your code in the\nlayer.\n\nDefine a `PythonLayerVersion`:\n\n```ts\nnew lambda.PythonLayerVersion(this, 'MyLayer', {\n entry: '/path/to/my/layer', // point this to your library's directory\n})\n```\n\nA layer can also be used as a part of a `PythonFunction`:\n\n```ts\nnew lambda.PythonFunction(this, 'MyFunction', {\n entry: '/path/to/my/function',\n runtime: Runtime.PYTHON_3_8,\n layers: [\n new lambda.PythonLayerVersion(this, 'MyLayer', {\n entry: '/path/to/my/layer', // point this to your library's directory\n }),\n ],\n});\n```\n\n## Packaging\n\nIf `requirements.txt`, `Pipfile` or `poetry.lock` exists at the entry path, the construct will handle installing all required modules in a [Lambda compatible Docker container](https://gallery.ecr.aws/sam/build-python3.7) according to the `runtime` and with the Docker platform based on the target architecture of the Lambda function.\n\nPython bundles are only recreated and published when a file in a source directory has changed.\nTherefore (and as a general best-practice), it is highly recommended to commit a lockfile with a\nlist of all transitive dependencies and their exact versions. This will ensure that when any dependency version is updated, the bundle asset is recreated and uploaded.\n\nTo that end, we recommend using [`pipenv`] or [`poetry`] which have lockfile support.\n\n- [`pipenv`](https://pipenv-fork.readthedocs.io/en/latest/basics.html#example-pipfile-lock)\n- [`poetry`](https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control)\n\nPackaging is executed using the `Packaging` class, which:\n\n1. Infers the packaging type based on the files present.\n2. If it sees a `Pipfile` or a `poetry.lock` file, it exports it to a compatible `requirements.txt` file with credentials (if they're available in the source files or in the bundling container).\n3. Installs dependencies using `pip`.\n4. Copies the dependencies into an asset that is bundled for the Lambda package.\n\n**Lambda with a requirements.txt**\n\n```plaintext\n.\n├── lambda_function.py # exports a function named 'handler'\n├── requirements.txt # has to be present at the entry path\n```\n\n**Lambda with a Pipfile**\n\n```plaintext\n.\n├── lambda_function.py # exports a function named 'handler'\n├── Pipfile # has to be present at the entry path\n├── Pipfile.lock # your lock file\n```\n\n**Lambda with a poetry.lock**\n\n```plaintext\n.\n├── lambda_function.py # exports a function named 'handler'\n├── pyproject.toml # your poetry project definition\n├── poetry.lock # your poetry lock file has to be present at the entry path\n```\n\n## Custom Bundling\n\nCustom bundling can be performed by passing in additional build arguments that point to index URLs to private repos, or by using an entirely custom Docker images for bundling dependencies. The build args currently supported are:\n\n- `PIP_INDEX_URL`\n- `PIP_EXTRA_INDEX_URL`\n- `HTTPS_PROXY`\n\nAdditional build args for bundling that refer to PyPI indexes can be specified as:\n\n```ts\nconst entry = '/path/to/function';\nconst image = DockerImage.fromBuild(entry);\n\nnew lambda.PythonFunction(this, 'function', {\n entry,\n runtime: Runtime.PYTHON_3_8,\n bundling: {\n buildArgs: { PIP_INDEX_URL: \"https://your.index.url/simple/\", PIP_EXTRA_INDEX_URL: \"https://your.extra-index.url/simple/\" },\n },\n});\n```\n\nIf using a custom Docker image for bundling, the dependencies are installed with `pip`, `pipenv` or `poetry` by using the `Packaging` class. A different bundling Docker image that is in the same directory as the function can be specified as:\n\n ```ts\nconst entry = '/path/to/function';\nconst image = DockerImage.fromBuild(entry);\n\nnew lambda.PythonFunction(this, 'function', {\n entry,\n runtime: Runtime.PYTHON_3_8,\n bundling: { image },\n});\n```\n\n## Custom Bundling with Code Artifact\n\nTo use a Code Artifact PyPI repo, the `PIP_INDEX_URL` for bundling the function can be customized (requires AWS CLI in the build environment):\n\n```ts\nimport { execSync } from 'child_process';\n\nconst entry = '/path/to/function';\nconst image = DockerImage.fromBuild(entry);\n\nconst domain = 'my-domain';\nconst domainOwner = '111122223333';\nconst repoName = 'my_repo';\nconst region = 'us-east-1';\nconst codeArtifactAuthToken = execSync(`aws codeartifact get-authorization-token --domain ${domain} --domain-owner ${domainOwner} --query authorizationToken --output text`).toString().trim();\n\nconst indexUrl = `https://aws:${codeArtifactAuthToken}@${domain}-${domainOwner}.d.codeartifact.${region}.amazonaws.com/pypi/${repoName}/simple/`;\n\nnew lambda.PythonFunction(this, 'function', {\n entry,\n runtime: Runtime.PYTHON_3_8,\n bundling: {\n environment: { PIP_INDEX_URL: indexUrl },\n },\n});\n```\n\nThe index URL or the token are only used during bundling and thus not included in the final asset. Setting only environment variable for `PIP_INDEX_URL` or `PIP_EXTRA_INDEX_URL` should work for accesing private Python repositories with `pip`, `pipenv` and `poetry` based dependencies.\n\nIf you also want to use the Code Artifact repo for building the base Docker image for bundling, use `buildArgs`. However, note that setting custom build args for bundling will force the base bundling image to be rebuilt every time (i.e. skip the Docker cache). Build args can be customized as:\n\n```ts\nimport { execSync } from 'child_process';\n\nconst entry = '/path/to/function';\nconst image = DockerImage.fromBuild(entry);\n\nconst domain = 'my-domain';\nconst domainOwner = '111122223333';\nconst repoName = 'my_repo';\nconst region = 'us-east-1';\nconst codeArtifactAuthToken = execSync(`aws codeartifact get-authorization-token --domain ${domain} --domain-owner ${domainOwner} --query authorizationToken --output text`).toString().trim();\n\nconst indexUrl = `https://aws:${codeArtifactAuthToken}@${domain}-${domainOwner}.d.codeartifact.${region}.amazonaws.com/pypi/${repoName}/simple/`;\n\nnew lambda.PythonFunction(this, 'function', {\n entry,\n runtime: Runtime.PYTHON_3_8,\n bundling: {\n buildArgs: { PIP_INDEX_URL: indexUrl },\n },\n});\n```\n" }, "repository": { "directory": "packages/@aws-cdk/aws-lambda-python", "type": "git", "url": "https://github.com/aws/aws-cdk.git" }, "schema": "jsii/0.10.0", "targets": { "dotnet": { "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", "namespace": "Amazon.CDK.AWS.Lambda.Python", "packageId": "Amazon.CDK.AWS.Lambda.Python" }, "java": { "maven": { "artifactId": "lambda-python", "groupId": "software.amazon.awscdk" }, "package": "software.amazon.awscdk.services.lambda.python" }, "js": { "npm": "@aws-cdk/aws-lambda-python" }, "python": { "classifiers": [ "Framework :: AWS CDK", "Framework :: AWS CDK :: 1" ], "distName": "aws-cdk.aws-lambda-python", "module": "aws_cdk.aws_lambda_python" } }, "types": { "@aws-cdk/aws-lambda-python.BundlingOptions": { "assembly": "@aws-cdk/aws-lambda-python", "datatype": true, "docs": { "stability": "experimental", "summary": "Options for bundling.", "example": "const entry = '/path/to/function';\nconst image = DockerImage.fromBuild(entry);\n\nnew lambda.PythonFunction(this, 'function', {\n entry,\n runtime: Runtime.PYTHON_3_8,\n bundling: {\n buildArgs: { PIP_INDEX_URL: \"https://your.index.url/simple/\", PIP_EXTRA_INDEX_URL: \"https://your.extra-index.url/simple/\" },\n },\n});", "custom": { "exampleMetadata": "infused" } }, "fqn": "@aws-cdk/aws-lambda-python.BundlingOptions", "kind": "interface", "locationInModule": { "filename": "lib/types.ts", "line": 7 }, "name": "BundlingOptions", "properties": [ { "abstract": true, "docs": { "default": "- Based on `assetHashType`", "remarks": "If `assetHashType` is set it must\nbe set to `AssetHashType.CUSTOM`. For consistency, this custom hash will\nbe SHA256 hashed and encoded as hex. The resulting hash will be the asset\nhash.\n\nNOTE: the hash is used in order to identify a specific revision of the asset, and\nused for optimizing and caching deployment activities related to this asset such as\npackaging, uploading to Amazon S3, etc. If you chose to customize the hash, you will\nneed to make sure it is updated every time the asset changes, or otherwise it is\npossible that some deployments will not be invalidated.", "stability": "experimental", "summary": "Specify a custom hash for this asset." }, "immutable": true, "locationInModule": { "filename": "lib/types.ts", "line": 78 }, "name": "assetHash", "optional": true, "type": { "primitive": "string" } }, { "abstract": true, "docs": { "default": "AssetHashType.SOURCE By default, hash is calculated based on the\ncontents of the source directory. This means that only updates to the\nsource will cause the asset to rebuild.", "remarks": "If asset hash is set to `SOURCE` (default), then only changes to the source\ndirectory will cause the asset to rebuild. This means, for example, that in\norder to pick up a new dependency version, a change must be made to the\nsource tree. Ideally, this can be implemented by including a dependency\nlockfile in your source tree or using fixed dependencies.\n\nIf the asset hash is set to `OUTPUT`, the hash is calculated after\nbundling. This means that any change in the output will cause the asset to\nbe invalidated and uploaded. Bear in mind that `pip` adds timestamps to\ndependencies it installs, which implies that in this mode Python bundles\nwill _always_ get rebuild and uploaded. Normally this is an anti-pattern\nsince build", "stability": "experimental", "summary": "Determines how asset hash is calculated. Assets will get rebuild and uploaded only if their hash has changed." }, "immutable": true, "locationInModule": { "filename": "lib/types.ts", "line": 62 }, "name": "assetHashType", "optional": true, "type": { "fqn": "@aws-cdk/core.AssetHashType" } }, { "abstract": true, "docs": { "default": "- No build arguments.", "remarks": "This can be used to customize\nthe index URLs used for installing dependencies.\nThis is not used if a custom image is provided.", "stability": "experimental", "summary": "Optional build arguments to pass to the default container." }, "immutable": true, "locationInModule": { "filename": "lib/types.ts", "line": 31 }, "name": "buildArgs", "optional": true, "type": { "collection": { "elementtype": { "primitive": "string" }, "kind": "map" } } }, { "abstract": true, "docs": { "default": "- no environment variables are defined.", "stability": "experimental", "summary": "Environment variables defined when bundling runs." }, "immutable": true, "locationInModule": { "filename": "lib/types.ts", "line": 38 }, "name": "environment", "optional": true, "type": { "collection": { "elementtype": { "primitive": "string" }, "kind": "map" } } }, { "abstract": true, "docs": { "default": "- Default bundling image.", "remarks": "If no options are provided, the default bundling image\nwill be used. Dependencies will be installed using the default packaging commands\nand copied over from into the Lambda asset.", "stability": "experimental", "summary": "Docker image to use for bundling." }, "immutable": true, "locationInModule": { "filename": "lib/types.ts", "line": 22 }, "name": "image", "optional": true, "type": { "fqn": "@aws-cdk/core.DockerImage" } }, { "abstract": true, "docs": { "default": "- 'python' for a layer, empty string otherwise.", "stability": "experimental", "summary": "Output path suffix: the suffix for the directory into which the bundled output is written." }, "immutable": true, "locationInModule": { "filename": "lib/types.ts", "line": 13 }, "name": "outputPathSuffix", "optional": true, "type": { "primitive": "string" } } ], "symbolId": "lib/types:BundlingOptions" }, "@aws-cdk/aws-lambda-python.PythonFunction": { "assembly": "@aws-cdk/aws-lambda-python", "base": "@aws-cdk/aws-lambda.Function", "docs": { "stability": "experimental", "summary": "A Python Lambda function.", "example": "const entry = '/path/to/function';\nconst image = DockerImage.fromBuild(entry);\n\nnew lambda.PythonFunction(this, 'function', {\n entry,\n runtime: Runtime.PYTHON_3_8,\n bundling: {\n buildArgs: { PIP_INDEX_URL: \"https://your.index.url/simple/\", PIP_EXTRA_INDEX_URL: \"https://your.extra-index.url/simple/\" },\n },\n});", "custom": { "exampleMetadata": "infused" } }, "fqn": "@aws-cdk/aws-lambda-python.PythonFunction", "initializer": { "docs": { "stability": "experimental" }, "locationInModule": { "filename": "lib/function.ts", "line": 58 }, "parameters": [ { "name": "scope", "type": { "fqn": "@aws-cdk/core.Construct" } }, { "name": "id", "type": { "primitive": "string" } }, { "name": "props", "type": { "fqn": "@aws-cdk/aws-lambda-python.PythonFunctionProps" } } ] }, "kind": "class", "locationInModule": { "filename": "lib/function.ts", "line": 57 }, "name": "PythonFunction", "symbolId": "lib/function:PythonFunction" }, "@aws-cdk/aws-lambda-python.PythonFunctionProps": { "assembly": "@aws-cdk/aws-lambda-python", "datatype": true, "docs": { "stability": "experimental", "summary": "Properties for a PythonFunction.", "example": "const entry = '/path/to/function';\nconst image = DockerImage.fromBuild(entry);\n\nnew lambda.PythonFunction(this, 'function', {\n entry,\n runtime: Runtime.PYTHON_3_8,\n bundling: {\n buildArgs: { PIP_INDEX_URL: \"https://your.index.url/simple/\", PIP_EXTRA_INDEX_URL: \"https://your.extra-index.url/simple/\" },\n },\n});", "custom": { "exampleMetadata": "infused" } }, "fqn": "@aws-cdk/aws-lambda-python.PythonFunctionProps", "interfaces": [ "@aws-cdk/aws-lambda.FunctionOptions" ], "kind": "interface", "locationInModule": { "filename": "lib/function.ts", "line": 16 }, "name": "PythonFunctionProps", "properties": [ { "abstract": true, "docs": { "stability": "experimental", "summary": "Path to the source of the function or the location for dependencies." }, "immutable": true, "locationInModule": { "filename": "lib/function.ts", "line": 20 }, "name": "entry", "type": { "primitive": "string" } }, { "abstract": true, "docs": { "default": "Runtime.PYTHON_3_7", "remarks": "Only runtimes of the Python family are\nsupported.", "stability": "experimental", "summary": "The runtime environment." }, "immutable": true, "locationInModule": { "filename": "lib/function.ts", "line": 29 }, "name": "runtime", "type": { "fqn": "@aws-cdk/aws-lambda.Runtime" } }, { "abstract": true, "docs": { "default": "- Use the default bundling Docker image, with x86_64 architecture.", "remarks": "Use this to specify custom bundling options like\nthe bundling Docker image, asset hash type, custom hash, architecture, etc.", "stability": "experimental", "summary": "Bundling options to use for this function." }, "immutable": true, "locationInModule": { "filename": "lib/function.ts", "line": 51 }, "name": "bundling", "optional": true, "type": { "fqn": "@aws-cdk/aws-lambda-python.BundlingOptions" } }, { "abstract": true, "docs": { "default": "handler", "stability": "experimental", "summary": "The name of the exported handler in the index file." }, "immutable": true, "locationInModule": { "filename": "lib/function.ts", "line": 43 }, "name": "handler", "optional": true, "type": { "primitive": "string" } }, { "abstract": true, "docs": { "default": "index.py", "stability": "experimental", "summary": "The path (relative to entry) to the index file containing the exported handler." }, "immutable": true, "locationInModule": { "filename": "lib/function.ts", "line": 36 }, "name": "index", "optional": true, "type": { "primitive": "string" } } ], "symbolId": "lib/function:PythonFunctionProps" }, "@aws-cdk/aws-lambda-python.PythonLayerVersion": { "assembly": "@aws-cdk/aws-lambda-python", "base": "@aws-cdk/aws-lambda.LayerVersion", "docs": { "stability": "experimental", "summary": "A lambda layer version.", "example": "new lambda.PythonLayerVersion(this, 'MyLayer', {\n entry: '/path/to/my/layer', // point this to your library's directory\n})", "custom": { "exampleMetadata": "infused" } }, "fqn": "@aws-cdk/aws-lambda-python.PythonLayerVersion", "initializer": { "docs": { "stability": "experimental" }, "locationInModule": { "filename": "lib/layer.ts", "line": 46 }, "parameters": [ { "name": "scope", "type": { "fqn": "@aws-cdk/core.Construct" } }, { "name": "id", "type": { "primitive": "string" } }, { "name": "props", "type": { "fqn": "@aws-cdk/aws-lambda-python.PythonLayerVersionProps" } } ] }, "kind": "class", "locationInModule": { "filename": "lib/layer.ts", "line": 45 }, "name": "PythonLayerVersion", "symbolId": "lib/layer:PythonLayerVersion" }, "@aws-cdk/aws-lambda-python.PythonLayerVersionProps": { "assembly": "@aws-cdk/aws-lambda-python", "datatype": true, "docs": { "stability": "experimental", "summary": "Properties for PythonLayerVersion.", "example": "new lambda.PythonLayerVersion(this, 'MyLayer', {\n entry: '/path/to/my/layer', // point this to your library's directory\n})", "custom": { "exampleMetadata": "infused" } }, "fqn": "@aws-cdk/aws-lambda-python.PythonLayerVersionProps", "interfaces": [ "@aws-cdk/aws-lambda.LayerVersionOptions" ], "kind": "interface", "locationInModule": { "filename": "lib/layer.ts", "line": 14 }, "name": "PythonLayerVersionProps", "properties": [ { "abstract": true, "docs": { "stability": "experimental", "summary": "The path to the root directory of the lambda layer." }, "immutable": true, "locationInModule": { "filename": "lib/layer.ts", "line": 18 }, "name": "entry", "type": { "primitive": "string" } }, { "abstract": true, "docs": { "default": "- Use the default bundling Docker image, with x86_64 architecture.", "remarks": "Use this to specify custom bundling options like\nthe bundling Docker image, asset hash type, custom hash, architecture, etc.", "stability": "experimental", "summary": "Bundling options to use for this function." }, "immutable": true, "locationInModule": { "filename": "lib/layer.ts", "line": 38 }, "name": "bundling", "optional": true, "type": { "fqn": "@aws-cdk/aws-lambda-python.BundlingOptions" } }, { "abstract": true, "docs": { "default": "[Architecture.X86_64]", "stability": "experimental", "summary": "The system architectures compatible with this layer." }, "immutable": true, "locationInModule": { "filename": "lib/layer.ts", "line": 31 }, "name": "compatibleArchitectures", "optional": true, "type": { "collection": { "elementtype": { "fqn": "@aws-cdk/aws-lambda.Architecture" }, "kind": "array" } } }, { "abstract": true, "docs": { "default": "- Only Python 3.7 is supported.", "stability": "experimental", "summary": "The runtimes compatible with the python layer." }, "immutable": true, "locationInModule": { "filename": "lib/layer.ts", "line": 25 }, "name": "compatibleRuntimes", "optional": true, "type": { "collection": { "elementtype": { "fqn": "@aws-cdk/aws-lambda.Runtime" }, "kind": "array" } } } ], "symbolId": "lib/layer:PythonLayerVersionProps" } }, "version": "1.204.0", "fingerprint": "**********" }