diff --git a/modules/cloud-function-v1/README.md b/modules/cloud-function-v1/README.md index cd8fbe86..ca432119 100644 --- a/modules/cloud-function-v1/README.md +++ b/modules/cloud-function-v1/README.md @@ -157,7 +157,7 @@ The Cloud Function bundle can be configured via the `bundle_config` variable, so If a `zip` archive is already available, simply set the archive path in `bundle_config.path`. If a dynamically generated archive is needed, set `bundle_config.path` to the source folder path, then optionally configure the path where the archive will be created, and any exclusions needed in the archive. -In order to help prevent `archive_zip.output_md5` from changing cross platform (e.g. Cloud Build vs your local development environment), you'll have to make sure that the files included in the zip are always the same. +If you use a folder and dynamic archive bundling, be mindful that the MD5 checksum of the generated `zip` file does not change across environments (e.g. Cloud Build vs your local development environment), by ensuring that the files in the folder are always the same. ```hcl module "cf-http" { diff --git a/modules/cloud-function-v1/bundle.tf b/modules/cloud-function-v1/bundle.tf index 2553d23a..8843672a 100644 --- a/modules/cloud-function-v1/bundle.tf +++ b/modules/cloud-function-v1/bundle.tf @@ -16,9 +16,9 @@ locals { bundle = { - md5 = try( - data.archive_file.bundle[0].output_md5, - data.local_file.bundle[0].content_md5 + name = try( + "bundle-${data.archive_file.bundle[0].output_md5}.zip", + basename(var.bundle_config.path) ) path = try( data.archive_file.bundle[0].output_path, @@ -57,7 +57,7 @@ resource "google_storage_bucket" "bucket" { } resource "google_storage_bucket_object" "bundle" { - name = "bundle-${local.bundle.md5}.zip" + name = local.bundle.name bucket = local.bucket source = local.bundle.path } @@ -72,10 +72,3 @@ data "archive_file" "bundle" { output_file_mode = "0644" excludes = var.bundle_config.excludes } - -data "local_file" "bundle" { - count = ( - try(fileexists(var.bundle_config.path), null) == null ? 0 : 1 - ) - filename = var.bundle_config.path -} diff --git a/modules/cloud-function-v2/README.md b/modules/cloud-function-v2/README.md index 78b05afc..f8bd9ead 100644 --- a/modules/cloud-function-v2/README.md +++ b/modules/cloud-function-v2/README.md @@ -171,7 +171,7 @@ The Cloud Function bundle can be configured via the `bundle_config` variable, so If a `zip` archive is already available, simply set the archive path in `bundle_config.path`. If a dynamically generated archive is needed, set `bundle_config.path` to the source folder path, then optionally configure the path where the archive will be created, and any exclusions needed in the archive. -In order to help prevent `archive_zip.output_md5` from changing cross platform (e.g. Cloud Build vs your local development environment), you'll have to make sure that the files included in the zip are always the same. +If you use a folder and dynamic archive bundling, be mindful that the MD5 checksum of the generated `zip` file does not change across environments (e.g. Cloud Build vs your local development environment), by ensuring that the files in the folder are always the same. ```hcl module "cf-http" { diff --git a/modules/cloud-function-v2/bundle.tf b/modules/cloud-function-v2/bundle.tf index 2553d23a..8843672a 100644 --- a/modules/cloud-function-v2/bundle.tf +++ b/modules/cloud-function-v2/bundle.tf @@ -16,9 +16,9 @@ locals { bundle = { - md5 = try( - data.archive_file.bundle[0].output_md5, - data.local_file.bundle[0].content_md5 + name = try( + "bundle-${data.archive_file.bundle[0].output_md5}.zip", + basename(var.bundle_config.path) ) path = try( data.archive_file.bundle[0].output_path, @@ -57,7 +57,7 @@ resource "google_storage_bucket" "bucket" { } resource "google_storage_bucket_object" "bundle" { - name = "bundle-${local.bundle.md5}.zip" + name = local.bundle.name bucket = local.bucket source = local.bundle.path } @@ -72,10 +72,3 @@ data "archive_file" "bundle" { output_file_mode = "0644" excludes = var.bundle_config.excludes } - -data "local_file" "bundle" { - count = ( - try(fileexists(var.bundle_config.path), null) == null ? 0 : 1 - ) - filename = var.bundle_config.path -}