DOC: updated doc about creating lambda layer

This commit is contained in:
xpk
2024-10-29 13:49:42 +08:00
parent d08b7cac59
commit 157dc4cf3d
7 changed files with 31 additions and 442 deletions
+31 -3
View File
@@ -1,5 +1,33 @@
# Steps to create a lambda python package
pip install dnspython -t ./
touch lambda_function.py
zip -r dist.zip .
## Create layer
cd layers
pip install dnspython -t python/lib/python3.12/site-packages/
Then in terraform, create an archive for the layer
```hcl
data "archive_file" "dnspython" {
source_dir = "layers"
type = "zip"
output_path = "layer-dnspython.zip"
}
resource "aws_lambda_layer_version" "dnspython" {
description = "Python3 DnsPython library"
depends_on = [data.archive_file.layer1]
filename = "layer-dnspython.zip"
layer_name = "Python3DnsLibrary"
license_info = "ISCL"
compatible_architectures = ["arm64", "x86_64"]
compatible_runtimes = ["python3.12"]
}
# In the lambda function, reference the layer
resource "aws_lambda_function" "myFunction" {
...
layers = [aws_lambda_layer_version.libraries.arn]
}
```