Skip to content

Commit e966874

Browse files
committed
requested updates
1 parent a6b2304 commit e966874

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +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 |
58+
| create\_bucket | Whether to create a new bucket or use an existing one. If false, `bucket_name` should reference the name of the alternate bucket to use. | bool | `"true"` | no |
5959
| description | The description of the function. | string | `"Processes events."` | no |
6060
| entry\_point | The name of a method in the function source which will be invoked when the function is executed. | string | n/a | yes |
6161
| environment\_variables | A set of key/value environment variable pairs to assign to the function. | map(string) | `<map>` | no |

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@ data "archive_file" "main" {
4848
}
4949

5050
resource "google_storage_bucket" "main" {
51+
count = var.create_bucket ? 1 : 0
5152
name = coalesce(var.bucket_name, var.name)
5253
force_destroy = var.bucket_force_destroy
5354
location = var.region
5455
project = var.project_id
5556
storage_class = "REGIONAL"
5657
labels = var.bucket_labels
5758
bucket_policy_only = true
58-
count = var.create_bucket == true ? 1 : 0
5959
}
6060

6161
resource "google_storage_bucket_object" "main" {
6262
name = "${data.archive_file.main.output_md5}-${basename(data.archive_file.main.output_path)}"
63-
bucket = var.create_bucket == true ? google_storage_bucket.main[0].name : var.bucket_name
63+
bucket = var.create_bucket ? google_storage_bucket.main[0].name : var.bucket_name
6464
source = data.archive_file.main.output_path
6565
content_disposition = "attachment"
6666
content_encoding = "gzip"
@@ -86,7 +86,7 @@ resource "google_cloudfunctions_function" "main" {
8686
labels = var.labels
8787
runtime = var.runtime
8888
environment_variables = var.environment_variables
89-
source_archive_bucket = var.create_bucket == true ? google_storage_bucket.main[0].name : var.bucket_name
89+
source_archive_bucket = var.create_bucket ? google_storage_bucket.main[0].name : var.bucket_name
9090
source_archive_object = google_storage_bucket_object.main.name
9191
project = var.project_id
9292
region = var.region

variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ variable "bucket_name" {
109109
variable "create_bucket" {
110110
type = bool
111111
default = true
112-
description = "Whether to create a new bucket or use an existing bucket with the bucket_name passed to the module."
112+
description = "Whether to create a new bucket or use an existing one. If false, `bucket_name` should reference the name of the alternate bucket to use."
113113
}
114114

115115
variable "bucket_force_destroy" {

0 commit comments

Comments
 (0)