From 1306f67b96f5ca7fb315f3b263588f15b585fc29 Mon Sep 17 00:00:00 2001 From: devuonocar Date: Mon, 30 Oct 2023 18:23:33 +0100 Subject: [PATCH] Add public_access_prevention --- modules/gcs/README.md | 1 + modules/gcs/main.tf | 1 + modules/gcs/variables.tf | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/modules/gcs/README.md b/modules/gcs/README.md index 8a26958d..a04f9656 100644 --- a/modules/gcs/README.md +++ b/modules/gcs/README.md @@ -196,6 +196,7 @@ module "bucket" { | [notification_config](variables.tf#L169) | GCS Notification configuration. | object({…}) | | null | | [objects_to_upload](variables.tf#L183) | Objects to be uploaded to bucket. | map(object({…})) | | {} | | [prefix](variables.tf#L209) | Optional prefix used to generate the bucket name. | string | | null | +| [public_access_prevention](variables.tf#L224) | Prevents public access to a bucket. Acceptable values are inherited or enforced. If inherited, the bucket uses public access prevention, only if the bucket is subject to the public access prevention organization policy constraint. | string | | "inherited" | | [requester_pays](variables.tf#L224) | Enables Requester Pays on a storage bucket. | bool | | null | | [retention_policy](variables.tf#L230) | Bucket retention policy. | object({…}) | | null | | [storage_class](variables.tf#L239) | Bucket storage class. | string | | "MULTI_REGIONAL" | diff --git a/modules/gcs/main.tf b/modules/gcs/main.tf index 1341e707..c19c7912 100644 --- a/modules/gcs/main.tf +++ b/modules/gcs/main.tf @@ -29,6 +29,7 @@ resource "google_storage_bucket" "bucket" { labels = var.labels default_event_based_hold = var.default_event_based_hold requester_pays = var.requester_pays + public_access_prevention = var.public_access_prevention versioning { enabled = var.versioning } diff --git a/modules/gcs/variables.tf b/modules/gcs/variables.tf index 350c74ba..4f7b9274 100644 --- a/modules/gcs/variables.tf +++ b/modules/gcs/variables.tf @@ -221,6 +221,12 @@ variable "project_id" { type = string } +variable "public_access_prevention" { + description = "Prevents public access to a bucket. Acceptable values are inherited or enforced. If inherited, the bucket uses public access prevention, only if the bucket is subject to the public access prevention organization policy constraint." + type = string + default = "inherited" +} + variable "requester_pays" { description = "Enables Requester Pays on a storage bucket." type = bool