Skip to content

Commit b739df3

Browse files
committed
Include again into the hash the content of package.py, ignoring its path
See PR #66 TODO: remove the code and logic for hash_extra_paths?
1 parent 9d3a7b1 commit b739df3

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

package.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@ def prepare_command(args):
16911691
if log.isEnabledFor(DEBUG3):
16921692
log.debug("QUERY: %s", json.dumps(query_data, indent=2))
16931693
else:
1694-
log_excludes = ("source_path", "hash_extra_paths", "paths")
1694+
log_excludes = ("source_path", "hash_extra_paths", "hash_internal", "paths")
16951695
qd = {k: v for k, v in query_data.items() if k not in log_excludes}
16961696
log.debug("QUERY (excerpt): %s", json.dumps(qd, indent=2))
16971697

@@ -1704,6 +1704,7 @@ def prepare_command(args):
17041704
hash_extra_paths = query.hash_extra_paths
17051705
source_path = query.source_path
17061706
hash_extra = query.hash_extra
1707+
hash_internal = query.hash_internal
17071708
recreate_missing_package = yesno_bool(
17081709
args.recreate_missing_package
17091710
if args.recreate_missing_package is not None
@@ -1723,6 +1724,8 @@ def prepare_command(args):
17231724
content_hash = bpm.hash(hash_extra_paths)
17241725
content_hash.update(json.dumps(build_plan, sort_keys=True).encode())
17251726
content_hash.update(runtime.encode())
1727+
for c in hash_internal:
1728+
content_hash.update(c.encode())
17261729
content_hash.update(hash_extra.encode())
17271730
content_hash = content_hash.hexdigest()
17281731

package.tf

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,13 @@ data "external" "archive_prepare" {
2626
docker_entrypoint = var.docker_entrypoint
2727
}) : null
2828

29-
artifacts_dir = var.artifacts_dir
30-
runtime = var.runtime
31-
source_path = try(tostring(var.source_path), jsonencode(var.source_path))
32-
hash_extra = var.hash_extra
33-
hash_extra_paths = jsonencode(
34-
[
35-
# Temporary fix when building from multiple locations
36-
# We should take into account content of package.py when counting hash
37-
# Related issue: https://github.com/terraform-aws-modules/terraform-aws-lambda/issues/63
38-
# "${path.module}/package.py"
39-
]
40-
)
29+
artifacts_dir = var.artifacts_dir
30+
runtime = var.runtime
31+
source_path = try(tostring(var.source_path), jsonencode(var.source_path))
32+
hash_extra = var.hash_extra
33+
hash_extra_paths = jsonencode([])
34+
# Include into the hash the module sources that affect the packaging.
35+
hash_internal = jsonencode([filesha256("${path.module}/package.py")])
4136

4237
recreate_missing_package = var.recreate_missing_package
4338
quiet = var.quiet_archive_local_exec

0 commit comments

Comments
 (0)