File tree Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ module "localhost_function" {
5555| bucket\_ force\_ destroy | When deleting the GCS bucket containing the cloud function, delete all objects in the bucket first. | bool | ` "false" ` | no |
5656| bucket\_ labels | A set of key/value label pairs to assign to the function source archive bucket. | map(string) | ` <map> ` | no |
5757| bucket\_ name | The name to apply to the bucket. Will default to a string of the function name. | string | ` "" ` | no |
58+ | create\_ bucket | Whether to create a new bucket or use an existing bucket with the bucket_name passed to the module. | bool | ` "true" ` | no |
5859| description | The description of the function. | string | ` "Processes events." ` | no |
5960| entry\_ point | The name of a method in the function source which will be invoked when the function is executed. | string | n/a | yes |
6061| environment\_ variables | A set of key/value environment variable pairs to assign to the function. | map(string) | ` <map> ` | no |
Original file line number Diff line number Diff line change @@ -55,11 +55,12 @@ resource "google_storage_bucket" "main" {
5555 storage_class = " REGIONAL"
5656 labels = var. bucket_labels
5757 bucket_policy_only = true
58+ count = var. create_bucket == true ? 1 : 0
5859}
5960
6061resource "google_storage_bucket_object" "main" {
6162 name = " ${ data . archive_file . main . output_md5 } -${ basename (data. archive_file . main . output_path )} "
62- bucket = google_storage_bucket. main . name
63+ bucket = var . create_bucket == true ? google_storage_bucket. main [ 0 ] . name : var . bucket_name
6364 source = data. archive_file . main . output_path
6465 content_disposition = " attachment"
6566 content_encoding = " gzip"
@@ -85,7 +86,7 @@ resource "google_cloudfunctions_function" "main" {
8586 labels = var. labels
8687 runtime = var. runtime
8788 environment_variables = var. environment_variables
88- source_archive_bucket = google_storage_bucket. main . name
89+ source_archive_bucket = var . create_bucket == true ? google_storage_bucket. main [ 0 ] . name : var . bucket_name
8990 source_archive_object = google_storage_bucket_object. main . name
9091 project = var. project_id
9192 region = var. region
Original file line number Diff line number Diff line change @@ -106,6 +106,12 @@ variable "bucket_name" {
106106 description = " The name to apply to the bucket. Will default to a string of the function name."
107107}
108108
109+ variable "create_bucket" {
110+ type = bool
111+ default = true
112+ description = " Whether to create a new bucket or use an existing bucket with the bucket_name passed to the module."
113+ }
114+
109115variable "bucket_force_destroy" {
110116 type = bool
111117 default = false
You can’t perform that action at this time.
0 commit comments