Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ignore_source_code_hash (#2)
* add ignore_changes_package (source code hash) var

* update CHANGELOG

* ignore_source_code_hash
  • Loading branch information
anoshi authored Jul 15, 2021
commit d156d8e156c6a38d107797891e89dc660ac2c3f4
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
<a name="unreleased"></a>
## [Unreleased]

- feat: Add `ignore_changes_package` variable to allow the lambda function resource to be managed by terraform but have the function code managed externally
- feat: Add `ignore_source_code_hash` variable to allow the lambda function resource to be managed by terraform but have the function code managed externally

<a name="v2.7.0"></a>
## [v2.7.0] - 2021-07-08
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ module "lambda_function_externally_managed_package" {
handler = "index.lambda_handler"
runtime = "python3.8"

create_package = false
local_existing_package = "../dummy_package.zip"
ignore_changes_package = true
create_package = false
local_existing_package = "./lambda_functions/dummy_lambda.zip"
ignore_source_code_hash = true
}
```

Expand Down
9 changes: 1 addition & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ resource "aws_lambda_function" "this" {
package_type = var.package_type

filename = local.filename
source_code_hash = (local.filename == null ? false : fileexists(local.filename)) && !local.was_missing ? filebase64sha256(local.filename) : null
source_code_hash = var.ignore_source_code_hash ? null : (local.filename == null ? false : fileexists(local.filename)) && !local.was_missing ? filebase64sha256(local.filename) : null

s3_bucket = local.s3_bucket
s3_key = local.s3_key
Expand Down Expand Up @@ -81,13 +81,6 @@ resource "aws_lambda_function" "this" {
}
}

dynamic "lifecycle" {
for_each = var.ignore_changes_package ? [true] : []
content {
ignore_changes = [source_code_hash]
}
}

tags = var.tags

# Depending on the log group is necessary to allow Terraform to create the log group before AWS can.
Expand Down
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,8 @@ variable "artifacts_dir" {
default = "builds"
}

variable "ignore_changes_package" {
description = "Set to true to ignore changes to the function's source code package/hash. Useful when infrastructure and code deployments are managed by separate pipelines"
variable "ignore_source_code_hash" {
description = "Set to true to ignore changes to the function's source code hash. Useful when infrastructure and code deployments are managed by separate pipelines"
type = bool
default = false
}
Expand Down