Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to project cloud storage public access prevention #740

Merged
merged 2 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ determining that location is as follows:
| bucket\_labels | A map of key/value label pairs to assign to the bucket (optional) | `map(string)` | `{}` | no |
| bucket\_location | The location for a GCS bucket to create (optional) | `string` | `"US"` | no |
| bucket\_name | A name for a GCS bucket to create (in the bucket\_project project), useful for Terraform state (optional) | `string` | `""` | no |
| bucket\_pap | Enable Public Access Prevention. Possible values are "enforced" or "inherited". | `string` | `"inherited"` | no |
| bucket\_project | A project to create a GCS bucket (bucket\_name) in, useful for Terraform state (optional) | `string` | `""` | no |
| bucket\_ula | Enable Uniform Bucket Level Access | `bool` | `true` | no |
| bucket\_versioning | Enable versioning for a GCS bucket to create (optional) | `bool` | `false` | no |
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ module "project-factory" {
bucket_labels = var.bucket_labels
bucket_force_destroy = var.bucket_force_destroy
bucket_ula = var.bucket_ula
bucket_pap = var.bucket_pap
auto_create_network = var.auto_create_network
disable_services_on_destroy = var.disable_services_on_destroy
default_service_account = var.default_service_account
Expand Down
3 changes: 3 additions & 0 deletions modules/core_project_factory/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ resource "google_project_usage_export_bucket" "usage_report_export" {
Project's bucket creation
***********************************************/
resource "google_storage_bucket" "project_bucket" {
provider = google-beta

count = local.create_bucket ? 1 : 0

name = local.project_bucket_name
Expand All @@ -290,6 +292,7 @@ resource "google_storage_bucket" "project_bucket" {
labels = var.bucket_labels
force_destroy = var.bucket_force_destroy
uniform_bucket_level_access = var.bucket_ula
public_access_prevention = var.bucket_pap

versioning {
enabled = var.bucket_versioning
Expand Down
6 changes: 6 additions & 0 deletions modules/core_project_factory/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ variable "bucket_ula" {
default = true
}

variable "bucket_pap" {
description = "Enable Public Access Prevention. Possible values are \"enforced\" or \"inherited\"."
type = string
default = "inherited"
}

variable "auto_create_network" {
description = "Create the default network"
type = bool
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ variable "bucket_ula" {
default = true
}

variable "bucket_pap" {
description = "Enable Public Access Prevention. Possible values are \"enforced\" or \"inherited\"."
type = string
default = "inherited"
}

variable "auto_create_network" {
description = "Create the default network"
type = bool
Expand Down