Skip to content

Commit 3d65014

Browse files
Merge branch 'master' into master
2 parents 9fa5c6d + 1d12240 commit 3d65014

File tree

11 files changed

+70
-1
lines changed

11 files changed

+70
-1
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.91.0
3+
rev: v1.92.2
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_wrapper_module_for_each

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [7.8.1](https://github.com/terraform-aws-modules/terraform-aws-lambda/compare/v7.8.0...v7.8.1) (2024-08-23)
6+
7+
8+
### Bug Fixes
9+
10+
* Fix package.py commands after :zip not being executed ([#606](https://github.com/terraform-aws-modules/terraform-aws-lambda/issues/606)) ([801e69c](https://github.com/terraform-aws-modules/terraform-aws-lambda/commit/801e69c08b74217e7f1319b128d5efd264162aaf))
11+
12+
## [7.8.0](https://github.com/terraform-aws-modules/terraform-aws-lambda/compare/v7.7.1...v7.8.0) (2024-08-23)
13+
14+
15+
### Features
16+
17+
* Added the skip_destroy argument for functions ([#600](https://github.com/terraform-aws-modules/terraform-aws-lambda/issues/600)) ([36c6109](https://github.com/terraform-aws-modules/terraform-aws-lambda/commit/36c61093dbb6114f9880d40b225e7f00f83493f9))
18+
519
## [7.7.1](https://github.com/terraform-aws-modules/terraform-aws-lambda/compare/v7.7.0...v7.7.1) (2024-07-25)
620

721

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,7 @@ No modules.
857857
| <a name="input_s3_object_tags_only"></a> [s3\_object\_tags\_only](#input\_s3\_object\_tags\_only) | Set to true to not merge tags with s3\_object\_tags. Useful to avoid breaching S3 Object 10 tag limit. | `bool` | `false` | no |
858858
| <a name="input_s3_prefix"></a> [s3\_prefix](#input\_s3\_prefix) | Directory name where artifacts should be stored in the S3 bucket. If unset, the path from `artifacts_dir` is used | `string` | `null` | no |
859859
| <a name="input_s3_server_side_encryption"></a> [s3\_server\_side\_encryption](#input\_s3\_server\_side\_encryption) | Specifies server-side encryption of the object in S3. Valid values are "AES256" and "aws:kms". | `string` | `null` | no |
860+
| <a name="input_skip_destroy"></a> [skip\_destroy](#input\_skip\_destroy) | Set to true if you do not wish the function to be deleted at destroy time, and instead just remove the function from the Terraform state. Useful for Lambda@Edge functions attached to CloudFront distributions. | `bool` | `null` | no |
860861
| <a name="input_snap_start"></a> [snap\_start](#input\_snap\_start) | (Optional) Snap start settings for low-latency startups | `bool` | `false` | no |
861862
| <a name="input_source_path"></a> [source\_path](#input\_source\_path) | The absolute path to a local file or directory containing your Lambda source code | `any` | `null` | no |
862863
| <a name="input_store_on_s3"></a> [store\_on\_s3](#input\_store\_on\_s3) | Whether to store produced artifacts on S3 or locally. | `bool` | `false` | no |

examples/build-package/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Note that this example may create resources which cost money. Run `terraform des
3737
| <a name="module_lambda_layer"></a> [lambda\_layer](#module\_lambda\_layer) | ../../ | n/a |
3838
| <a name="module_lambda_layer_pip_requirements"></a> [lambda\_layer\_pip\_requirements](#module\_lambda\_layer\_pip\_requirements) | ../.. | n/a |
3939
| <a name="module_lambda_layer_poetry"></a> [lambda\_layer\_poetry](#module\_lambda\_layer\_poetry) | ../../ | n/a |
40+
| <a name="module_npm_package_with_commands_and_patterns"></a> [npm\_package\_with\_commands\_and\_patterns](#module\_npm\_package\_with\_commands\_and\_patterns) | ../../ | n/a |
4041
| <a name="module_package_dir"></a> [package\_dir](#module\_package\_dir) | ../../ | n/a |
4142
| <a name="module_package_dir_pip_dir"></a> [package\_dir\_pip\_dir](#module\_package\_dir\_pip\_dir) | ../../ | n/a |
4243
| <a name="module_package_dir_poetry"></a> [package\_dir\_poetry](#module\_package\_dir\_poetry) | ../../ | n/a |

examples/build-package/main.tf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,31 @@ module "package_with_commands_and_patterns" {
244244
]
245245
}
246246

247+
# Some use cases might require the production packages are deployed while maintaining local node_modules folder
248+
# This example saves the node_modules folder by moving it to an ignored directory
249+
# After the zip file is created with production node_modules, the dev node_modules folder is restored
250+
module "npm_package_with_commands_and_patterns" {
251+
source = "../../"
252+
253+
create_function = false
254+
255+
runtime = "nodejs18.x"
256+
source_path = [
257+
{
258+
path = "${path.module}/../fixtures/node-app"
259+
commands = [
260+
"[ ! -d node_modules ] || mv node_modules node_modules_temp",
261+
"npm install --production",
262+
":zip",
263+
"rm -rf node_modules",
264+
"[ ! -d node_modules_temp ] || mv node_modules_temp node_modules",
265+
]
266+
patterns = [
267+
"!node_modules_temp/.*"
268+
]
269+
}
270+
]
271+
}
247272
# Create zip-archive with various sources and patterns.
248273
# Note, that it is possible to write comments in patterns.
249274
module "package_with_patterns" {

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ resource "aws_lambda_function" "this" {
4141
code_signing_config_arn = var.code_signing_config_arn
4242
replace_security_groups_on_destroy = var.replace_security_groups_on_destroy
4343
replacement_security_group_ids = var.replacement_security_group_ids
44+
skip_destroy = var.skip_destroy
4445

4546
/* ephemeral_storage is not supported in gov-cloud region, so it should be set to `null` */
4647
dynamic "ephemeral_storage" {

package.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,9 @@ def commands_step(path, commands):
779779
)
780780
else:
781781
batch.append(c)
782+
if batch:
783+
step("sh", path, "\n".join(batch))
784+
batch.clear()
782785

783786
for claim in claims:
784787
if isinstance(claim, str):

tests/fixtures/node-app/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// test

tests/fixtures/node-app/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "app",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "",
10+
"license": "ISC",
11+
"dependencies": {
12+
},
13+
"devDependencies": {
14+
"axios": "^1.7.3"
15+
}
16+
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ variable "timeouts" {
260260
default = {}
261261
}
262262

263+
variable "skip_destroy" {
264+
description = "Set to true if you do not wish the function to be deleted at destroy time, and instead just remove the function from the Terraform state. Useful for Lambda@Edge functions attached to CloudFront distributions."
265+
type = bool
266+
default = null
267+
}
268+
263269
###############
264270
# Function URL
265271
###############

wrappers/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ module "wrapper" {
120120
s3_object_tags_only = try(each.value.s3_object_tags_only, var.defaults.s3_object_tags_only, false)
121121
s3_prefix = try(each.value.s3_prefix, var.defaults.s3_prefix, null)
122122
s3_server_side_encryption = try(each.value.s3_server_side_encryption, var.defaults.s3_server_side_encryption, null)
123+
skip_destroy = try(each.value.skip_destroy, var.defaults.skip_destroy, null)
123124
snap_start = try(each.value.snap_start, var.defaults.snap_start, false)
124125
source_path = try(each.value.source_path, var.defaults.source_path, null)
125126
store_on_s3 = try(each.value.store_on_s3, var.defaults.store_on_s3, false)

0 commit comments

Comments
 (0)