don't compute checksum in cloud function module for static bundles (#2359)
This commit is contained in:
parent
97d77d263b
commit
cb5b36906c
|
@ -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.
|
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
|
```hcl
|
||||||
module "cf-http" {
|
module "cf-http" {
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
|
|
||||||
locals {
|
locals {
|
||||||
bundle = {
|
bundle = {
|
||||||
md5 = try(
|
name = try(
|
||||||
data.archive_file.bundle[0].output_md5,
|
"bundle-${data.archive_file.bundle[0].output_md5}.zip",
|
||||||
data.local_file.bundle[0].content_md5
|
basename(var.bundle_config.path)
|
||||||
)
|
)
|
||||||
path = try(
|
path = try(
|
||||||
data.archive_file.bundle[0].output_path,
|
data.archive_file.bundle[0].output_path,
|
||||||
|
@ -57,7 +57,7 @@ resource "google_storage_bucket" "bucket" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "google_storage_bucket_object" "bundle" {
|
resource "google_storage_bucket_object" "bundle" {
|
||||||
name = "bundle-${local.bundle.md5}.zip"
|
name = local.bundle.name
|
||||||
bucket = local.bucket
|
bucket = local.bucket
|
||||||
source = local.bundle.path
|
source = local.bundle.path
|
||||||
}
|
}
|
||||||
|
@ -72,10 +72,3 @@ data "archive_file" "bundle" {
|
||||||
output_file_mode = "0644"
|
output_file_mode = "0644"
|
||||||
excludes = var.bundle_config.excludes
|
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
|
|
||||||
}
|
|
||||||
|
|
|
@ -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.
|
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
|
```hcl
|
||||||
module "cf-http" {
|
module "cf-http" {
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
|
|
||||||
locals {
|
locals {
|
||||||
bundle = {
|
bundle = {
|
||||||
md5 = try(
|
name = try(
|
||||||
data.archive_file.bundle[0].output_md5,
|
"bundle-${data.archive_file.bundle[0].output_md5}.zip",
|
||||||
data.local_file.bundle[0].content_md5
|
basename(var.bundle_config.path)
|
||||||
)
|
)
|
||||||
path = try(
|
path = try(
|
||||||
data.archive_file.bundle[0].output_path,
|
data.archive_file.bundle[0].output_path,
|
||||||
|
@ -57,7 +57,7 @@ resource "google_storage_bucket" "bucket" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "google_storage_bucket_object" "bundle" {
|
resource "google_storage_bucket_object" "bundle" {
|
||||||
name = "bundle-${local.bundle.md5}.zip"
|
name = local.bundle.name
|
||||||
bucket = local.bucket
|
bucket = local.bucket
|
||||||
source = local.bundle.path
|
source = local.bundle.path
|
||||||
}
|
}
|
||||||
|
@ -72,10 +72,3 @@ data "archive_file" "bundle" {
|
||||||
output_file_mode = "0644"
|
output_file_mode = "0644"
|
||||||
excludes = var.bundle_config.excludes
|
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
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue