Skip to content

Commit

Permalink
Use unique bundle name for Cloud Function
Browse files Browse the repository at this point in the history
When cloud-function module is used multiple times within project and
default `bundle_config.output_path` is used then all the instances try
to use filename and result is undefined without guarantee to converge to
desired state (i.e. multiple functions may share the same code).
  • Loading branch information
wiktorn committed Mar 27, 2023
1 parent 987ea34 commit eb2e2cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions modules/cloud-function/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ resource "google_storage_bucket_object" "bundle" {
data "archive_file" "bundle" {
type = "zip"
source_dir = var.bundle_config.source_dir
output_path = var.bundle_config.output_path
output_file_mode = "0666"
output_path = var.bundle_config.output_path != null ? var.bundle_config.output_path : "/tmp/bundle-${var.project_id}-${var.name}.zip"
output_file_mode = "0644"
excludes = var.bundle_config.excludes
}

Expand Down
2 changes: 1 addition & 1 deletion modules/cloud-function/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ variable "bundle_config" {
description = "Cloud function source folder and generated zip bundle paths. Output path defaults to '/tmp/bundle.zip' if null."
type = object({
source_dir = string
output_path = optional(string, "/tmp/bundle.zip")
output_path = optional(string)
excludes = optional(list(string))
})
}
Expand Down

0 comments on commit eb2e2cb

Please sign in to comment.