Skip to content

Commit

Permalink
Merge pull request #234 from jx3rocks/delete_protect
Browse files Browse the repository at this point in the history
fix: allow cluster deletion (terraform-google-jx#233)
  • Loading branch information
jenkins-x-bot authored Dec 23, 2023
2 parents 70108bc + 9eb8071 commit e18bc9f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ For more information on how to configure and use a custom domain, refer to [Usin
If you just want to experiment with Jenkins X, you can set `force_destroy` to `true`.
This allows you to remove all generated resources when running `terraform destroy`, including any generated buckets including their content.

If you want to remove a cluster with the `terraform destroy` command and the cluster is protected by the `deletion_protection=true` attribute, you can override the attribute by setting the `delete_protect` variable to `false`. It is recommended to override this value and the time of cluster deletion and you should successfully apply the attribute value change before attempting the `terraform destroy` command.

The following two paragraphs provide the full list of configuration and output variables of this Terraform module.

#### Inputs
Expand All @@ -117,6 +119,7 @@ The following two paragraphs provide the full list of configuration and output v
| cluster\_network | The name of the network (VPC) to which the cluster is connected | `string` | `"default"` | no |
| cluster\_subnetwork | The name of the subnetwork to which the cluster is connected. Leave blank when using the 'default' vpc to generate a subnet for your cluster | `string` | `""` | no |
| create\_ui\_sa | Whether the service accounts for the UI should be created | `bool` | `true` | no |
| delete\_protect | Flag used to set the `deletion_protection` attribute to prevent cluster deletion | `bool` | `true` | no |
| dev\_env\_approvers | List of git users allowed to approve pull request for dev enviornment repository | `list(string)` | `[]` | no |
| enable\_backup | Whether or not Velero backups should be enabled | `bool` | `false` | no |
| enable\_private\_endpoint | (Beta) Whether the master's internal IP address is used as the cluster endpoint. Requires VPC-native | `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 @@ -173,6 +173,7 @@ module "cluster" {
jx_git_operator_version = var.jx_git_operator_version

kuberhealthy = var.kuberhealthy
delete_protect = var.delete_protect
}

// ----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions modules/cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ resource "google_container_cluster" "jx_cluster" {
location = var.cluster_location
network = var.cluster_network
subnetwork = var.cluster_subnetwork
deletion_protection = var.delete_protect
enable_kubernetes_alpha = var.enable_kubernetes_alpha
enable_legacy_abac = var.enable_legacy_abac
enable_shielded_nodes = var.enable_shielded_nodes
Expand Down
7 changes: 7 additions & 0 deletions modules/cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -511,3 +511,10 @@ variable "content" {
type = string
default = ""
}

variable "delete_protect" {
description = "Flag used to set the `deletion_protection` attribute to prevent cluster deletion"
type = bool
default = true
}

7 changes: 7 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,10 @@ variable "kuberhealthy" {
type = bool
default = true
}

variable "delete_protect" {
description = "Flag used to set the `deletion_protection` attribute to prevent cluster deletion"
type = bool
default = true
}

0 comments on commit e18bc9f

Please sign in to comment.