Skip to content

Commit

Permalink
feat: Add recreate_missing_package parameter in addition to TF_RECREA…
Browse files Browse the repository at this point in the history
…TE_MISSING_LAMBDA_PACKAGE environment variable
  • Loading branch information
pdecat committed Aug 21, 2021
1 parent 87d8a58 commit 3a4ea75
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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."` ?

Expand Down Expand Up @@ -715,6 +715,7 @@ No modules.
| <a name="input_policy_statements"></a> [policy\_statements](#input\_policy\_statements) | Map of dynamic policy statements to attach to Lambda Function role | `any` | `{}` | no |
| <a name="input_provisioned_concurrent_executions"></a> [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 |
| <a name="input_publish"></a> [publish](#input\_publish) | Whether to publish creation/change as new Lambda Function Version. | `bool` | `false` | no |
| <a name="input_recreate_missing_package"></a> [recreate\_missing\_package](#input\_recreate\_missing\_package) | Whether to recreate missing Lambda package if it is missing locally or not | `bool` | `true` | no |
| <a name="input_reserved_concurrent_executions"></a> [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 |
| <a name="input_role_description"></a> [role\_description](#input\_role\_description) | Description of IAM role to use for Lambda Function | `string` | `null` | no |
| <a name="input_role_force_detach_policies"></a> [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 |
Expand Down
4 changes: 2 additions & 2 deletions package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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'),
)

Expand Down
2 changes: 2 additions & 0 deletions package.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ data "external" "archive_prepare" {
# "${path.module}/package.py"
]
)

recreate_missing_package = var.recreate_missing_package
}
}

Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 3a4ea75

Please sign in to comment.