Skip to content

Commit

Permalink
fix: Add force_destroy option for included GCS bucket (#545)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmackett authored Mar 30, 2021
1 parent 365407f commit 1774999
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ determining that location is as follows:
| activate\_apis | The list of apis to activate within the project | `list(string)` | <pre>[<br> "compute.googleapis.com"<br>]</pre> | no |
| auto\_create\_network | Create the default network | `bool` | `false` | no |
| billing\_account | The ID of the billing account to associate this project with | `string` | n/a | yes |
| bucket\_force\_destroy | Force the deletion of all objects within the GCS bucket when deleting the bucket (optional) | `bool` | `false` | no |
| bucket\_labels | A map of key/value label pairs to assign to the bucket (optional) | `map` | `{}` | 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 |
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ module "project-factory" {
bucket_location = var.bucket_location
bucket_versioning = var.bucket_versioning
bucket_labels = var.bucket_labels
bucket_force_destroy = var.bucket_force_destroy
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
9 changes: 5 additions & 4 deletions modules/core_project_factory/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,11 @@ resource "google_project_usage_export_bucket" "usage_report_export" {
resource "google_storage_bucket" "project_bucket" {
count = local.create_bucket ? 1 : 0

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
labels = var.bucket_labels
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
labels = var.bucket_labels
force_destroy = var.bucket_force_destroy

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_labels" {
default = {}
}

variable "bucket_force_destroy" {
description = "Force the deletion of all objects within the GCS bucket when deleting the bucket (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 @@ -181,6 +181,12 @@ variable "bucket_labels" {
default = {}
}

variable "bucket_force_destroy" {
description = "Force the deletion of all objects within the GCS bucket when deleting the bucket (optional)"
type = bool
default = false
}

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

0 comments on commit 1774999

Please sign in to comment.