Skip to content

Commit d95d76c

Browse files
authored
chore: Added example for pip install in layers (#214)
1 parent e84892e commit d95d76c

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

examples/build-package/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Note that this example may create resources which cost money. Run `terraform des
3535
|------|--------|---------|
3636
| <a name="module_lambda_function_from_package"></a> [lambda\_function\_from\_package](#module\_lambda\_function\_from\_package) | ../../ | |
3737
| <a name="module_lambda_layer"></a> [lambda\_layer](#module\_lambda\_layer) | ../../ | |
38+
| <a name="module_lambda_layer_pip_requirements"></a> [lambda\_layer\_pip\_requirements](#module\_lambda\_layer\_pip\_requirements) | ../.. | |
3839
| <a name="module_package_dir"></a> [package\_dir](#module\_package\_dir) | ../../ | |
3940
| <a name="module_package_dir_without_pip_install"></a> [package\_dir\_without\_pip\_install](#module\_package\_dir\_without\_pip\_install) | ../../ | |
4041
| <a name="module_package_file"></a> [package\_file](#module\_package\_file) | ../../ | |

examples/build-package/main.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,25 @@ module "lambda_function_from_package" {
247247
module.lambda_layer.lambda_layer_arn
248248
]
249249
}
250+
251+
################################################
252+
# Layer that supports requirements.txt install #
253+
###############################################
254+
module "lambda_layer_pip_requirements" {
255+
source = "../.."
256+
257+
create_function = false
258+
create_layer = true
259+
260+
layer_name = "${random_pet.this.id}-layer-pip-requirements"
261+
compatible_runtimes = ["python3.8"]
262+
runtime = "python3.8" # required to force layers to do pip install
263+
264+
source_path = [
265+
{
266+
path = "${path.module}/../fixtures/python3.8-app1"
267+
pip_requirements = true
268+
prefix_in_zip = "python" # required to get the path correct
269+
}
270+
]
271+
}

0 commit comments

Comments
 (0)