Skip to content

Commit

Permalink
feat(TPG>=5.31)!: add cloud storage filename datetime format support (#…
Browse files Browse the repository at this point in the history
…192)

Co-authored-by: Lauren Huang <[email protected]>
Co-authored-by: Imran Nayer <[email protected]>
  • Loading branch information
3 people authored Jun 28, 2024
1 parent c310330 commit 46a264b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,15 @@ module "pubsub" {
]
cloud_storage_subscriptions = [
{
name = "cloud-storage" // required
bucket = "example-bucket" // required
filename_prefix = "log_events_" // optional
filename_suffix = ".avro" // optional
max_duration = "60s" // optional
max_bytes = "10000000" // optional
output_format = "avro" // optional
write_metadata = false // optional
name = "cloud-storage" // required
bucket = "example-bucket" // required
filename_prefix = "log_events_" // optional
filename_suffix = ".avro" // optional
filename_datetime_format = "YYYY-MM-DD/hh_mm_ssZ" // optional
max_duration = "60s" // optional
max_bytes = "10000000" // optional
output_format = "avro" // optional
write_metadata = false // optional
}
]
}
Expand Down
3 changes: 3 additions & 0 deletions examples/cloud_storage/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ module "pubsub" {
name = "example_bucket_subscription"
bucket = google_storage_bucket.test.name

filename_prefix = "example_prefix_"
filename_suffix = "_example_suffix"
filename_datetime_format = "YYYY-MM-DD/hh_mm_ssZ"
ack_deadline_seconds = 300
},
]
Expand Down
11 changes: 6 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,12 @@ resource "google_pubsub_subscription" "cloud_storage_subscriptions" {
}

cloud_storage_config {
bucket = each.value["bucket"]
filename_prefix = lookup(each.value, "filename_prefix", null)
filename_suffix = lookup(each.value, "filename_suffix", null)
max_duration = lookup(each.value, "max_duration", null)
max_bytes = lookup(each.value, "max_bytes", null)
bucket = each.value["bucket"]
filename_prefix = lookup(each.value, "filename_prefix", null)
filename_suffix = lookup(each.value, "filename_suffix", null)
filename_datetime_format = lookup(each.value, "filename_datetime_format", null)
max_duration = lookup(each.value, "max_duration", null)
max_bytes = lookup(each.value, "max_bytes", null)
dynamic "avro_config" {
for_each = (lookup(each.value, "output_format", "") == "avro") ? [true] : []
content {
Expand Down
4 changes: 2 additions & 2 deletions test/setup/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 4.78"
version = ">= 5.31"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.78"
version = ">= 5.31"
}
null = {
source = "hashicorp/null"
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ terraform {

google = {
source = "hashicorp/google"
version = ">= 4.78, < 6"
version = ">= 5.31, < 6"
}
}

Expand Down

0 comments on commit 46a264b

Please sign in to comment.