From dc686c3a84dba0df9707931724297940fd409843 Mon Sep 17 00:00:00 2001 From: Ludovico Magnocavallo Date: Fri, 24 May 2024 09:02:33 +0200 Subject: [PATCH] Remove default location from gcs module (#2303) * gcs module * blueprints/apigee/bigquery-analytics * tfdoc * pubsub README md syntax --- blueprints/apigee/bigquery-analytics/main.tf | 1 + modules/folder/README.md | 1 + modules/gcs/README.md | 13 +++++++++++-- modules/gcs/variables.tf | 2 +- modules/organization/README.md | 1 + modules/project/README.md | 2 ++ modules/pubsub/README.md | 3 ++- modules/pubsub/variables.tf | 1 - tests/fixtures/gcs.tf | 3 ++- 9 files changed, 21 insertions(+), 6 deletions(-) diff --git a/blueprints/apigee/bigquery-analytics/main.tf b/blueprints/apigee/bigquery-analytics/main.tf index b90bec0712..5e8404283e 100644 --- a/blueprints/apigee/bigquery-analytics/main.tf +++ b/blueprints/apigee/bigquery-analytics/main.tf @@ -136,6 +136,7 @@ module "bucket_export" { source = "../../../modules/gcs" project_id = module.project.project_id name = "${module.project.project_id}-export" + location = var.organization.analytics_region iam = { "roles/storage.objectViewer" = [ module.function_gcs2bq.service_account_iam_email diff --git a/modules/folder/README.md b/modules/folder/README.md index ff242aeec0..219df4c1b3 100644 --- a/modules/folder/README.md +++ b/modules/folder/README.md @@ -209,6 +209,7 @@ module "gcs" { project_id = var.project_id prefix = var.prefix name = "gcs_sink" + location = "EU" force_destroy = true } diff --git a/modules/gcs/README.md b/modules/gcs/README.md index d94a40dbeb..e05d4602f8 100644 --- a/modules/gcs/README.md +++ b/modules/gcs/README.md @@ -21,6 +21,7 @@ module "bucket" { project_id = var.project_id prefix = var.prefix name = "my-bucket" + location = "EU" versioning = true labels = { cost-center = "devops" @@ -62,8 +63,8 @@ module "bucket" { project_id = var.project_id prefix = var.prefix name = "my-bucket" - encryption_key = module.kms.keys.bucket_key.id location = "EU" + encryption_key = module.kms.keys.bucket_key.id } # tftest modules=3 skip e2e @@ -77,6 +78,7 @@ module "bucket" { project_id = var.project_id prefix = var.prefix name = "my-bucket" + location = "EU" retention_policy = { retention_period = 100 is_locked = true @@ -98,6 +100,7 @@ module "bucket" { project_id = var.project_id prefix = var.prefix name = "my-bucket" + location = "EU" lifecycle_rules = { lr-0 = { action = { @@ -127,6 +130,7 @@ module "bucket-gcs-notification" { project_id = var.project_id prefix = var.prefix name = "my-bucket" + location = "EU" notification_config = { enabled = true payload_format = "JSON_API_V1" @@ -147,6 +151,7 @@ module "bucket" { project_id = var.project_id prefix = var.prefix name = "my-bucket" + location = "EU" objects_to_upload = { sample-data = { name = "example-file.csv" @@ -176,6 +181,7 @@ module "bucket" { project_id = var.project_id prefix = var.prefix name = "my-bucket" + location = "EU" iam = { "roles/storage.admin" = ["group:${var.group_email}"] } @@ -189,6 +195,7 @@ module "bucket" { project_id = var.project_id prefix = var.prefix name = "my-bucket" + location = "EU" iam_bindings = { storage-admin-with-delegated_roles = { role = "roles/storage.admin" @@ -217,6 +224,7 @@ module "bucket" { project_id = var.project_id prefix = var.prefix name = "my-bucket" + location = "EU" iam_bindings_additive = { storage-admin-with-delegated_roles = { role = "roles/storage.admin" @@ -264,6 +272,7 @@ module "bucket" { project_id = var.project_id prefix = var.prefix name = "my-bucket" + location = "EU" tag_bindings = { env-sandbox = module.org.tag_values["environment/sandbox"].id } @@ -275,6 +284,7 @@ module "bucket" { | name | description | type | required | default | |---|---|:---:|:---:|:---:| +| [location](variables.tf#L149) | Bucket location. | string | ✓ | | | [name](variables.tf#L164) | Bucket name suffix. | string | ✓ | | | [project_id](variables.tf#L219) | Bucket project id. | string | ✓ | | | [autoclass](variables.tf#L17) | Enable autoclass to automatically transition objects to appropriate storage classes based on their access pattern. If set to true, storage_class must be set to STANDARD. Defaults to false. | bool | | false | @@ -288,7 +298,6 @@ module "bucket" { | [iam_bindings_additive](variables.tf#L79) | Individual additive IAM bindings. Keys are arbitrary. | map(object({…})) | | {} | | [labels](variables.tf#L94) | Labels to be attached to all buckets. | map(string) | | {} | | [lifecycle_rules](variables.tf#L100) | Bucket lifecycle rule. | map(object({…})) | | {} | -| [location](variables.tf#L149) | Bucket location. | string | | "EU" | | [logging_config](variables.tf#L155) | Bucket logging configuration. | object({…}) | | null | | [notification_config](variables.tf#L169) | GCS Notification configuration. | object({…}) | | null | | [objects_to_upload](variables.tf#L183) | Objects to be uploaded to bucket. | map(object({…})) | | {} | diff --git a/modules/gcs/variables.tf b/modules/gcs/variables.tf index 993a855fea..b33f2d5b08 100644 --- a/modules/gcs/variables.tf +++ b/modules/gcs/variables.tf @@ -149,7 +149,7 @@ variable "lifecycle_rules" { variable "location" { description = "Bucket location." type = string - default = "EU" + # default = "EU" } variable "logging_config" { diff --git a/modules/organization/README.md b/modules/organization/README.md index f0253d11b3..7a4421cd1f 100644 --- a/modules/organization/README.md +++ b/modules/organization/README.md @@ -272,6 +272,7 @@ module "gcs" { project_id = var.project_id prefix = var.prefix name = "gcs_sink" + location = "EU" force_destroy = true } diff --git a/modules/project/README.md b/modules/project/README.md index cd92870a47..8d88d0cae4 100644 --- a/modules/project/README.md +++ b/modules/project/README.md @@ -543,6 +543,7 @@ module "gcs" { source = "./fabric/modules/gcs" project_id = var.project_id name = "gcs_sink" + location = "EU" prefix = var.prefix force_destroy = true } @@ -1133,6 +1134,7 @@ module "gcs" { source = "./fabric/modules/gcs" project_id = var.project_id name = "gcs_sink" + location = "EU" prefix = var.prefix force_destroy = true } diff --git a/modules/pubsub/README.md b/modules/pubsub/README.md index 4aaa4a4812..856deab1b9 100644 --- a/modules/pubsub/README.md +++ b/modules/pubsub/README.md @@ -141,6 +141,7 @@ module "pubsub" { } # tftest modules=2 resources=4 fixtures=fixtures/gcs.tf inventory=cloud-storage-subscription.yaml e2e ``` + ### Subscriptions with IAM ```hcl @@ -173,7 +174,7 @@ module "pubsub" { | [message_retention_duration](variables.tf#L67) | Minimum duration to retain a message after it is published to the topic. | string | | null | | [regions](variables.tf#L83) | List of regions used to set persistence policy. | list(string) | | [] | | [schema](variables.tf#L90) | Topic schema. If set, all messages in this topic should follow this schema. | object({…}) | | null | -| [subscriptions](variables.tf#L100) | Topic subscriptions. Also define push configs for push subscriptions. If options is set to null subscription defaults will be used. Labels default to topic labels if set to null. | map(object({…})) | | {} | +| [subscriptions](variables.tf#L100) | Topic subscriptions. Also define push configs for push subscriptions. If options is set to null subscription defaults will be used. Labels default to topic labels if set to null. | map(object({…})) | | {} | ## Outputs diff --git a/modules/pubsub/variables.tf b/modules/pubsub/variables.tf index 370c42fa77..6ea20f6d52 100644 --- a/modules/pubsub/variables.tf +++ b/modules/pubsub/variables.tf @@ -116,7 +116,6 @@ variable "subscriptions" { minimum_backoff = optional(number) maximum_backoff = optional(number) })) - bigquery = optional(object({ table = string use_topic_schema = optional(bool, false) diff --git a/tests/fixtures/gcs.tf b/tests/fixtures/gcs.tf index 107a36e4d1..86309aef67 100644 --- a/tests/fixtures/gcs.tf +++ b/tests/fixtures/gcs.tf @@ -17,7 +17,8 @@ module "gcs" { project_id = var.project_id prefix = var.prefix name = "my-bucket" + location = "EU" iam = { "roles/storage.admin" = ["serviceAccount:service-${var.project_number}@gcp-sa-pubsub.iam.gserviceaccount.com"] } -} \ No newline at end of file +}