Skip to content

Commit

Permalink
feat: Enable GCS bucket versioning (#431)
Browse files Browse the repository at this point in the history
Co-authored-by: Morgante Pell <morgantep@google.com>
  • Loading branch information
askoriy and morgante authored Jul 22, 2020
1 parent c954990 commit 7a0d746
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ determining that location is as follows:
| 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\_project | A project to create a GCS bucket (bucket_name) in, useful for Terraform state (optional) | string | `""` | no |
| bucket\_versioning | Enable versioning for a GCS bucket to create (optional) | bool | `"false"` | no |
| budget\_alert\_pubsub\_topic | The name of the Cloud Pub/Sub topic where budget related messages will be published, in the form of `projects/{project_id}/topics/{topic_id}` | string | `"null"` | no |
| budget\_alert\_spent\_percents | A list of percentages of the budget to alert on when threshold is exceeded | list(number) | `<list>` | no |
| budget\_amount | The amount to use for a budget alert | number | `"null"` | no |
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ module "project-factory" {
bucket_project = var.bucket_project
bucket_name = var.bucket_name
bucket_location = var.bucket_location
bucket_versioning = var.bucket_versioning
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
4 changes: 4 additions & 0 deletions modules/core_project_factory/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ resource "google_storage_bucket" "project_bucket" {
name = local.project_bucket_name
project = var.bucket_project == local.base_project_id ? google_project.main.project_id : var.bucket_project
location = var.bucket_location

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 @@ -143,6 +143,12 @@ variable "bucket_location" {
default = "US"
}

variable "bucket_versioning" {
description = "Enable versioning for a GCS bucket to create (optional)"
type = bool
default = false
}

variable "auto_create_network" {
description = "Create the default network"
type = bool
Expand Down
1 change: 1 addition & 0 deletions modules/gsuite_enabled/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ The roles granted are specifically:
| bucket\_location | The location for a GCS bucket to create (optional) | string | `""` | no |
| bucket\_name | A name for a GCS bucket to create (in the bucket_project project), useful for Terraform state (optional) | string | `""` | no |
| bucket\_project | A project to create a GCS bucket (bucket_name) in, useful for Terraform state (optional) | string | `""` | no |
| bucket\_versioning | Enable versioning for a GCS bucket to create (optional) | bool | `"false"` | no |
| budget\_alert\_pubsub\_topic | The name of the Cloud Pub/Sub topic where budget related messages will be published, in the form of `projects/{project_id}/topics/{topic_id}` | string | `"null"` | no |
| budget\_alert\_spent\_percents | A list of percentages of the budget to alert on when threshold is exceeded | list(number) | `<list>` | no |
| budget\_amount | The amount to use for a budget alert | number | `"null"` | no |
Expand Down
1 change: 1 addition & 0 deletions modules/gsuite_enabled/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ module "project-factory" {
bucket_project = var.bucket_project
bucket_name = var.bucket_name
bucket_location = var.bucket_location
bucket_versioning = var.bucket_versioning
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
6 changes: 6 additions & 0 deletions modules/gsuite_enabled/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ variable "bucket_location" {
default = ""
}

variable "bucket_versioning" {
description = "Enable versioning for a GCS bucket to create (optional)"
type = bool
default = false
}

variable "api_sa_group" {
description = "A G Suite group to place the Google APIs Service Account for the project in"
default = ""
Expand Down
1 change: 1 addition & 0 deletions modules/shared_vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module "project-factory" {
activate_apis = var.activate_apis
usage_bucket_name = var.usage_bucket_name
usage_bucket_prefix = var.usage_bucket_prefix
bucket_versioning = var.bucket_versioning
credentials_path = var.credentials_path
shared_vpc_subnets = var.shared_vpc_subnets
labels = var.labels
Expand Down
6 changes: 6 additions & 0 deletions modules/shared_vpc/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ variable "bucket_location" {
default = "US"
}

variable "bucket_versioning" {
description = "Enable versioning for a GCS bucket to create (optional)"
type = bool
default = false
}

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 @@ -137,6 +137,12 @@ variable "bucket_location" {
default = "US"
}

variable "bucket_versioning" {
description = "Enable versioning for a GCS bucket to create (optional)"
type = bool
default = false
}

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

0 comments on commit 7a0d746

Please sign in to comment.