/** * # lambda-layers * * Download python packages and create lambda layer * * ## Notes * Packages need to be placed under a python/ subdirectory. * See https://docs.aws.amazon.com/lambda/latest/dg/packaging-layers.html */ # build python package zip file module "lambda_archive" { source = "../modules/compute/LambdaZipBuilder" pip_packages = "pandas numpy pytz openpyxl" upload_archive_to_s3 = true s3_bucket_name = module.s3.bucket_name pip_path = "/my/work/xpk-git/venv314/bin/pip3" } # create lambda layer resource "aws_lambda_layer_version" "pandas" { description = "Python packages pandas numpy pytz openpyxl" s3_bucket = module.s3.bucket_name s3_key = module.lambda_archive.s3_object_key source_code_hash = module.lambda_archive.s3_object_hash layer_name = "py_packages" compatible_runtimes = ["python3.13"] } # s3 bucket required for uploading python package zip module "s3" { source = "../modules/storage/s3_bucket_2023" bucket_name = "lab-lambdalayer-${random_uuid.this.result}" bucket_force_destroy = true enable_bucket_logging = false enable_bucket_lifecycle = false enable_versioning = false enable_encryption = true } resource "random_uuid" "this" {}