Use unique bundle name for Cloud Function
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).
This commit is contained in:
parent
987ea34d93
commit
082301c09c
|
@ -226,7 +226,7 @@ module "cf-http" {
|
||||||
| name | description | type | required | default |
|
| name | description | type | required | default |
|
||||||
|---|---|:---:|:---:|:---:|
|
|---|---|:---:|:---:|:---:|
|
||||||
| [bucket_name](variables.tf#L26) | Name of the bucket that will be used for the function code. It will be created with prefix prepended if bucket_config is not null. | <code>string</code> | ✓ | |
|
| [bucket_name](variables.tf#L26) | Name of the bucket that will be used for the function code. It will be created with prefix prepended if bucket_config is not null. | <code>string</code> | ✓ | |
|
||||||
| [bundle_config](variables.tf#L37) | Cloud function source folder and generated zip bundle paths. Output path defaults to '/tmp/bundle.zip' if null. | <code title="object({ source_dir = string output_path = optional(string, "/tmp/bundle.zip") excludes = optional(list(string)) })">object({…})</code> | ✓ | |
|
| [bundle_config](variables.tf#L37) | Cloud function source folder and generated zip bundle paths. Output path defaults to '/tmp/bundle.zip' if null. | <code title="object({ source_dir = string output_path = optional(string) excludes = optional(list(string)) })">object({…})</code> | ✓ | |
|
||||||
| [name](variables.tf#L94) | Name used for cloud function and associated resources. | <code>string</code> | ✓ | |
|
| [name](variables.tf#L94) | Name used for cloud function and associated resources. | <code>string</code> | ✓ | |
|
||||||
| [project_id](variables.tf#L109) | Project id used for all resources. | <code>string</code> | ✓ | |
|
| [project_id](variables.tf#L109) | Project id used for all resources. | <code>string</code> | ✓ | |
|
||||||
| [bucket_config](variables.tf#L17) | Enable and configure auto-created bucket. Set fields to null to use defaults. | <code title="object({ location = optional(string) lifecycle_delete_age_days = optional(number) })">object({…})</code> | | <code>null</code> |
|
| [bucket_config](variables.tf#L17) | Enable and configure auto-created bucket. Set fields to null to use defaults. | <code title="object({ location = optional(string) lifecycle_delete_age_days = optional(number) })">object({…})</code> | | <code>null</code> |
|
||||||
|
|
|
@ -267,8 +267,8 @@ resource "google_storage_bucket_object" "bundle" {
|
||||||
data "archive_file" "bundle" {
|
data "archive_file" "bundle" {
|
||||||
type = "zip"
|
type = "zip"
|
||||||
source_dir = var.bundle_config.source_dir
|
source_dir = var.bundle_config.source_dir
|
||||||
output_path = var.bundle_config.output_path
|
output_path = var.bundle_config.output_path != null ? var.bundle_config.output_path : "/tmp/bundle-${var.project_id}-${var.name}.zip"
|
||||||
output_file_mode = "0666"
|
output_file_mode = "0644"
|
||||||
excludes = var.bundle_config.excludes
|
excludes = var.bundle_config.excludes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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."
|
description = "Cloud function source folder and generated zip bundle paths. Output path defaults to '/tmp/bundle.zip' if null."
|
||||||
type = object({
|
type = object({
|
||||||
source_dir = string
|
source_dir = string
|
||||||
output_path = optional(string, "/tmp/bundle.zip")
|
output_path = optional(string)
|
||||||
excludes = optional(list(string))
|
excludes = optional(list(string))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue