Skip to content

Commit

Permalink
fix for example
Browse files Browse the repository at this point in the history
pe-artefact committed May 10, 2023
1 parent c9e0ec2 commit 38493c4
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -163,7 +163,7 @@ No requirements.
| project_id | GCP project ID | `string` | n/as | yes |
| location | GCP location | `string` | `europe-west1` | no |
| labels | Bucket labels | `map(string)` | `{}` | no |
| buckets | Name of the buckets to create | `list(string)` | n/a | yes |
| buckets_config | Main config of the buckets to create | `list(string)` | n/a | yes |
| lifecycle_rules | Lifecycle rules to define for each bucket | `list(object({delay = number storage_class = string})) ` | `[{"delay" : 60,"storage_class" : "ARCHIVE",}] ` | no |
| naming convention | Naming convention for each bucket | `object({prefix= string suffix=string})` | `{"prefix" : "", "suffix" : ""}` | no |

7 changes: 4 additions & 3 deletions examples/standalone/main.tf
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ locals {
}

provider "google" {
project = local.project_id
user_project_override = true
billing_project = local.project_id
}
@@ -22,8 +23,8 @@ module "datalake" {

# Optional: defines the naming convention to use for the buckets created by the module.
naming_convention = {
"prefix" : local.project_id
"suffix" : random_string.suffix.result
"prefix" : "${local.project_id}-"
"suffix" : "-${random_string.suffix.result}"
}

# Main config for all your buckets. Each dictionnary corresponds to one bucket.
@@ -56,7 +57,7 @@ module "datalake" {
],

# Optional: Notifications will be sent to the Cloud Pub/Sub topic named "TOPIC" when objects are created, updated, or deleted in the bucket.
"notification_topic" : "test"
"notification_topic" : "TOPIC"
}
]
}
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ resource "google_storage_bucket" "buckets" {
for_each = tomap({ for bucket_config in var.buckets_config : bucket_config.bucket_name => bucket_config })

labels = var.labels
name = "${var.naming_convention.prefix}-${each.value.bucket_name}-${var.naming_convention.suffix}"
name = "${var.naming_convention.prefix}${each.value.bucket_name}${var.naming_convention.suffix}"
location = var.location

force_destroy = false
@@ -46,15 +46,15 @@ resource "google_storage_bucket" "buckets" {

resource "google_storage_bucket_iam_member" "member" {
for_each = { for entry in local.iam_list : "${entry.bucket_name}.${entry.role}.${entry.principal}" => entry }
bucket = "${var.naming_convention.prefix}-${each.value.bucket_name}-${var.naming_convention.suffix}"
bucket = "${var.naming_convention.prefix}${each.value.bucket_name}${var.naming_convention.suffix}"
role = each.value.role
member = each.value.principal
depends_on = [google_storage_bucket.buckets]
}

resource "google_storage_notification" "notification" {
for_each = tomap({ for bucket_config in var.buckets_config : bucket_config.bucket_name => bucket_config if bucket_config.notification_topic != null })
bucket = "${var.naming_convention.prefix}-${each.value.bucket_name}-${var.naming_convention.suffix}"
bucket = "${var.naming_convention.prefix}${each.value.bucket_name}${var.naming_convention.suffix}"
payload_format = "JSON_API_V1"
topic = each.value.notification_topic
event_types = ["OBJECT_FINALIZE", "OBJECT_DELETE", "OBJECT_ARCHIVE", "OBJECT_METADATA_UPDATE"]

0 comments on commit 38493c4

Please sign in to comment.