From 3a4ea7590d5680ed936d1e8effde716923ee2078 Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Fri, 16 Jul 2021 09:42:00 +0200 Subject: [PATCH] feat: Add recreate_missing_package parameter in addition to TF_RECREATE_MISSING_LAMBDA_PACKAGE environment variable --- README.md | 3 ++- package.py | 4 ++-- package.tf | 2 ++ variables.tf | 6 ++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b657f60f..b735ab1f 100644 --- a/README.md +++ b/README.md @@ -545,7 +545,7 @@ Q2: How to force recreate deployment package? Q3: `null_resource.archive[0] must be replaced` -> Answer: This probably mean that zip-archive has been deployed, but is currently absent locally, and it has to be recreated locally. When you run into this issue during CI/CD process (where workspace is clean), you can set environment variable `TF_RECREATE_MISSING_LAMBDA_PACKAGE=false` and run `terraform apply`. +> Answer: This probably mean that zip-archive has been deployed, but is currently absent locally, and it has to be recreated locally. When you run into this issue during CI/CD process (where workspace is clean) or from multiple workspaces, you can set environment variable `TF_RECREATE_MISSING_LAMBDA_PACKAGE=false` or pass `recreate_missing_package = false` as a parameter to the module and run `terraform apply`. Q4: What does this error mean - `"We currently do not support adding policies for $LATEST."` ? @@ -715,6 +715,7 @@ No modules. | [policy\_statements](#input\_policy\_statements) | Map of dynamic policy statements to attach to Lambda Function role | `any` | `{}` | no | | [provisioned\_concurrent\_executions](#input\_provisioned\_concurrent\_executions) | Amount of capacity to allocate. Set to 1 or greater to enable, or set to 0 to disable provisioned concurrency. | `number` | `-1` | no | | [publish](#input\_publish) | Whether to publish creation/change as new Lambda Function Version. | `bool` | `false` | no | +| [recreate\_missing\_package](#input\_recreate\_missing\_package) | Whether to recreate missing Lambda package if it is missing locally or not | `bool` | `true` | no | | [reserved\_concurrent\_executions](#input\_reserved\_concurrent\_executions) | The amount of reserved concurrent executions for this Lambda Function. A value of 0 disables Lambda Function from being triggered and -1 removes any concurrency limitations. Defaults to Unreserved Concurrency Limits -1. | `number` | `-1` | no | | [role\_description](#input\_role\_description) | Description of IAM role to use for Lambda Function | `string` | `null` | no | | [role\_force\_detach\_policies](#input\_role\_force\_detach\_policies) | Specifies to force detaching any policies the IAM role has before destroying it. | `bool` | `true` | no | diff --git a/package.py b/package.py index 98613118..3b818d1a 100644 --- a/package.py +++ b/package.py @@ -1039,7 +1039,7 @@ def prepare_command(args): hash_extra_paths = query.hash_extra_paths source_path = query.source_path hash_extra = query.hash_extra - recreate_missing_package = yesno_bool(args.recreate_missing_package) + recreate_missing_package = yesno_bool(args.recreate_missing_package if args.recreate_missing_package is not None else query.recreate_missing_package) docker = query.docker bpm = BuildPlanManager(args, log=log) @@ -1227,7 +1227,7 @@ def main(): pattern_comments=yesno_bool(os.environ.get( 'TF_LAMBDA_PACKAGE_PATTERN_COMMENTS', False)), recreate_missing_package=os.environ.get( - 'TF_RECREATE_MISSING_LAMBDA_PACKAGE', True), + 'TF_RECREATE_MISSING_LAMBDA_PACKAGE', None), log_level=os.environ.get('TF_LAMBDA_PACKAGE_LOG_LEVEL', 'INFO'), ) diff --git a/package.tf b/package.tf index c6433965..ca473a48 100644 --- a/package.tf +++ b/package.tf @@ -36,6 +36,8 @@ data "external" "archive_prepare" { # "${path.module}/package.py" ] ) + + recreate_missing_package = var.recreate_missing_package } } diff --git a/variables.tf b/variables.tf index 56af85ca..8a4e6274 100644 --- a/variables.tf +++ b/variables.tf @@ -588,3 +588,9 @@ variable "docker_pip_cache" { type = any default = null } + +variable "recreate_missing_package" { + description = "Whether to recreate missing Lambda package if it is missing locally or not" + type = bool + default = true +} \ No newline at end of file