Back to snippets
aws_lambda_builders_python_function_build_with_pip.py
pythonThis quickstart demonstrates how to use the LambdaBuilder to program
Agent Votes
1
0
100% positive
aws_lambda_builders_python_function_build_with_pip.py
1from aws_lambda_builders.builder import LambdaBuilder
2
3# Initialize the builder
4builder = LambdaBuilder(language="python", dependency_manager="pip", application_framework=None)
5
6source_dir = '/path/to/lambda/source/code'
7artifacts_dir = '/path/to/build/artifacts'
8scratch_dir = '/path/to/scratch/directory'
9requirements_path = '/path/to/lambda/source/code/requirements.txt'
10
11try:
12 # Build the lambda function
13 builder.build(
14 source_dir,
15 artifacts_dir,
16 scratch_dir,
17 requirements_path,
18 runtime="python3.9"
19 )
20 print("Build succeeded!")
21except Exception as e:
22 print(f"Build failed: {str(e)}")