Skip to content

Commit 36c6109

Browse files
feat: Added the skip_destroy argument for functions (#600)
Co-authored-by: Anton Babenko <anton@antonbabenko.com>
1 parent f48be17 commit 36c6109

File tree

5 files changed

+10
-1
lines changed

5 files changed

+10
-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

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ No modules.
855855
| <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 |
856856
| <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 |
857857
| <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 |
858+
| <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 |
858859
| <a name="input_snap_start"></a> [snap\_start](#input\_snap\_start) | (Optional) Snap start settings for low-latency startups | `bool` | `false` | no |
859860
| <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 |
860861
| <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 |

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" {

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ variable "timeouts" {
254254
default = {}
255255
}
256256

257+
variable "skip_destroy" {
258+
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."
259+
type = bool
260+
default = null
261+
}
262+
257263
###############
258264
# Function URL
259265
###############

wrappers/main.tf

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

0 commit comments

Comments
 (0)