Skip to content

Commit 038f877

Browse files
committed
Updated examples and readme
1 parent e5c71e0 commit 038f877

File tree

15 files changed

+254
-109
lines changed

15 files changed

+254
-109
lines changed

README.md

+22-4
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ Hash of zip-archive created with the same content of the files is always identic
312312

313313
When calling this module multiple times in one execution to create packages with the same `source_path`, zip-archives will be corrupted due to concurrent writes into the same file. There are two solutions - set different values for `hash_extra` to create different archives, or create package once outside (using this module) and then pass `local_existing_package` argument to create other Lambda resources.
314314

315+
316+
## <a name="build"></a> Debug
317+
315318
Building and packaging has been historically hard to debug (especially with Terraform), so we made an effort to make it easier for user to see debug info. There are 3 different debug levels: `DEBUG` - to see only what is happening during planning phase, `DEBUG2` - to see all logging values, `DEBUG3` - to see all logging values and env variables (be careful sharing your env variables as they may contain secrets!).
316319

317320
User can specify debug level like this:
@@ -321,6 +324,14 @@ export TF_LAMBDA_PACKAGE_LOG_LEVEL=DEBUG2
321324
terraform apply
322325
```
323326

327+
User can enable comments in heredoc strings in `patterns` which can be helpful in some situations. To do this set this environment variable:
328+
329+
```
330+
export TF_LAMBDA_PACKAGE_PATTERN_COMMENTS=true
331+
terraform apply
332+
```
333+
334+
324335
## <a name="build"></a> Build Dependencies
325336

326337
You can specify `source_path` in a variety of ways to achieve desired flexibility when building deployment packages locally or in Docker. You can use absolute or relative paths.
@@ -340,11 +351,12 @@ When `source_path` is set to a list of directories the content of each will be t
340351

341352
### Combine various options for extreme flexibility
342353

343-
This is the most complete way of creating a deployment package from multiple sources with multiple dependencies. This example is showing all the available options:
354+
This is the most complete way of creating a deployment package from multiple sources with multiple dependencies. This example is showing some of the available options (see [examples/build-package](https://github.com/terraform-aws-modules/terraform-aws-lambda/tree/master/examples/build-package) for more):
344355

345356
```hcl
346357
source_path = [
347358
"src/main-source",
359+
"src/another-source/index.py",
348360
{
349361
path = "src/function1-dep",
350362
patterns = [
@@ -357,6 +369,11 @@ source_path = [
357369
}, {
358370
path = "src/python3.8-app2",
359371
pip_requirements = "requirements-large.txt",
372+
patterns = [
373+
"!vendor/colorful-0.5.4.dist-info/RECORD",
374+
"!vendor/colorful-.+.dist-info/.*",
375+
"!vendor/colorful/__pycache__/?.*",
376+
]
360377
}, {
361378
path = "src/python3.8-app3",
362379
commands = ["npm install"],
@@ -394,7 +411,7 @@ Few notes:
394411
```
395412

396413
* `commands` - List of commands to run. If specified, this argument overrides `pip_requirements`.
397-
* `pip_requirements` - Set to `true` to run `pip install` with `requirements.txt` found in `path`. Or set to another filename which you want to use instead.
414+
* `pip_requirements` - Controls whether to execute `pip install`. Set to `false` to disable this feature, `true` to run `pip install` with `requirements.txt` found in `path`. Or set to another filename which you want to use instead.
398415
* `prefix_in_zip` - If specified, will be used as a prefix inside zip-archive. By default, everything installs into the root of zip-archive.
399416

400417

@@ -429,6 +446,7 @@ When creating archive locally outside of this module you need to set `create_pac
429446
}
430447
```
431448

449+
432450
### Using deployment package from remote URL
433451

434452
This can be implemented in two steps: download file locally using CURL, and pass path to deployment package as `local_existing_package` argument.
@@ -494,9 +512,9 @@ There is [deploy module](https://github.com/terraform-aws-modules/terraform-aws-
494512

495513
## FAQ
496514

497-
Q1: Why deployment package not recreating every time I change something?
515+
Q1: Why deployment package not recreating every time I change something? Or why deployment package is being recreated every time but content has not been changed?
498516

499-
A1: There can be tons of reasons. The most likely is that changes has happened inside of dependency which is not used in calculating content hash. You can force it by setting value of `hash_extra` or to delete previously built package locally.
517+
A1: There can be several reasons related to concurrent executions, or to content hash. Sometimes, changes has happened inside of dependency which is not used in calculating content hash. Or multiple packages are creating at the same time from the same sources. You can force it by setting value of `hash_extra` to distinct values.
500518

501519
Q2: How to force recreate deployment package?
502520

examples/build-package/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Lambda Build Package Examples
1+
# Build Package Examples
22

3-
Configuration in this directory creates Lambda Function and Layer using various build and package options.
3+
Configuration in this directory creates deployment packages in a variety of combinations.
44

55
## Usage
66

0 commit comments

Comments
 (0)