Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody committed Oct 23, 2023
1 parent c3a6035 commit e746402
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
3 changes: 2 additions & 1 deletion examples/cloud_storage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ This example illustrates how to use the `pubsub` module.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| bucket\_name | The name of the GCS bucket name to which to write messages | `string` | n/a | yes |
| bucket\_name | The name of the GCS bucket name to which to write messages | `string` | `"test_bucket"` | no |
| project\_id | The project ID to manage the Pub/Sub resources | `string` | n/a | yes |
| random\_bucket\_suffix | Add a randomized 4-character suffix to bucket name | `bool` | `true` | no |

## Outputs

Expand Down
16 changes: 8 additions & 8 deletions examples/cloud_storage/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018 Google LLC
* Copyright 2018-2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,6 +14,11 @@
* limitations under the License.
*/

resource "random_id" "bucket_suffix" {
count = var.random_bucket_suffix ? 1 : 0
byte_length = 4
}

provider "google" {
region = "europe-west1"
}
Expand All @@ -26,18 +31,13 @@ module "pubsub" {
cloud_storage_subscriptions = [
{
name = "example_subscription"
bucket = var.bucket_name
bucket = google_storage_bucket.test.name
},
]

depends_on = [
google_storage_bucket.test
]

}

resource "google_storage_bucket" "test" {
project = var.project_id
name = var.bucket_name
name = var.random_bucket_suffix ? join("-", [var.bucket_name, random_id.bucket_suffix]) : var.bucket_name
location = "europe-west1"
}
4 changes: 2 additions & 2 deletions examples/cloud_storage/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018 Google LLC
* Copyright 2018-2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,7 @@ output "project_id" {
}

output "bucket_name" {
value = var.bucket_name
value = google_storage_bucket.test.name
description = "The name of the Cloud Storage bucket created"
}

Expand Down
8 changes: 8 additions & 0 deletions examples/cloud_storage/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ variable "project_id" {
type = string
description = "The project ID to manage the Pub/Sub resources"
}

variable "bucket_name" {
type = string
description = "The name of the GCS bucket name to which to write messages"
default = "test_bucket"
}

variable "random_bucket_suffix" {
type = bool
description = "Add a randomized 4-character suffix to bucket name"
default = true
}

0 comments on commit e746402

Please sign in to comment.