Skip to content

Commit da45049

Browse files
authored
feat: make force_destroy configurable (#703)
Use a variable to set the force_destroy attribute of the Cloud Storage bucket to store the Terraform state. This is helpful to simplify the related tutorial because we can ask users to adjust the value of the variable, instead of asking them to modify the source code.
1 parent 16a4216 commit da45049

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

storage/remote_terraform_backend_template/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ To run this example, do the following:
1616

1717
terraform init -migrate-state
1818

19-
20-
2119
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2220
## Inputs
2321

24-
No inputs.
22+
| Name | Description | Type | Default | Required |
23+
|------|-------------|------|---------|:--------:|
24+
| terraform\_state\_bucket\_force\_destroy | Set this to true to enable destroying the Terraform remote state Cloud Storage bucket | `bool` | `false` | no |
2525

2626
## Outputs
2727

storage/remote_terraform_backend_template/main.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,21 @@ resource "google_storage_bucket" "default" {
2222
name = "${random_id.default.hex}-terraform-remote-backend"
2323
location = "US"
2424

25-
force_destroy = false
25+
force_destroy = var.terraform_state_bucket_force_destroy
2626
public_access_prevention = "enforced"
2727
uniform_bucket_level_access = true
2828

2929
versioning {
3030
enabled = true
3131
}
3232
}
33+
34+
variable "terraform_state_bucket_force_destroy" {
35+
description = "Set this to true to enable destroying the Terraform remote state Cloud Storage bucket"
36+
default = false
37+
type = bool
38+
}
39+
3340
# [END storage_bucket_tf_with_versioning_pap_uap_no_destroy]
3441

3542
# [START storage_remote_backend_local_file]

0 commit comments

Comments
 (0)