Skip to content

Commit 1bbc5d4

Browse files
authored
Merge pull request #91 from worldcoin/lb-deletion-protection
feat: add enable_deletion_protection variable to control LB deletion protection
2 parents 1009c61 + 991a3e7 commit 1bbc5d4

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,13 @@ To remove the cluster you have to:
534534
```
535535

536536
1. Set these flags, the module will remove every usage of the Kubernetes provider and allow
537-
you to remove the cluster module without any errors.
537+
you to remove the cluster module without any errors. Setting `enable_deletion_protection = false`
538+
disables deletion protection on the Traefik NLB/ALB load balancers so they can be removed by Terraform.
538539

539540
```yaml
540-
efs_csi_driver_enabled = false
541+
efs_csi_driver_enabled = false
541542
kubernetes_provider_enabled = false
543+
enable_deletion_protection = false
542544
```
543545

544546
1. If above PR `apply` fails (possible reason: race condition - aws_auth removed too soon), remove all `kubernetes_*` resources from state:
@@ -549,8 +551,6 @@ To remove the cluster you have to:
549551
terraform state rm ...
550552
```
551553

552-
1. Manually remove LB deletion protection from AWS (both external and internal) before final delete
553-
554554
1. if there are other clusters in the same region, remove `aws_cloudwatch_event_rule.spot_aws_health aws_cloudwatch_event_rule.spot_aws_ec2` from the state manually.
555555

556556
1. Remove module invocation to finally delete cluster itself.

kubernetes-traefik-external.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ resource "kubernetes_ingress_v1" "treafik_ingress" {
9393
}
9494

9595
module "alb" {
96-
source = "git@github.com:worldcoin/terraform-aws-alb.git?ref=v1.3.2"
96+
source = "git@github.com:worldcoin/terraform-aws-alb.git?ref=v1.4.1"
9797
for_each = var.external_alb_enabled ? toset([local.external_alb_name]) : []
9898

9999
# because of lenght limitation of LB name we need to remove prefix treafik from internal NLB
@@ -123,6 +123,8 @@ module "alb" {
123123
mtls_enabled = var.open_to_all ? false : var.mtls_enabled
124124
mtls_s3_bucket = format("wld-mtls-ca-%s", var.region)
125125

126+
enable_deletion_protection = var.enable_deletion_protection
127+
126128
datadog = {
127129
monitoring_notification_channel = var.monitoring_notification_channel
128130
}

kubernetes-traefik-internal.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ resource "kubernetes_service_v1" "traefik_nlb" {
7070
}
7171

7272
module "nlb" {
73-
source = "git@github.com:worldcoin/terraform-aws-nlb.git?ref=v1.2.0"
73+
source = "git@github.com:worldcoin/terraform-aws-nlb.git?ref=v1.3.0"
7474

7575
for_each = var.internal_nlb_enabled ? toset([local.internal_nlb_name]) : []
7676

@@ -89,4 +89,6 @@ module "nlb" {
8989
private_subnets = var.use_private_subnets_for_internal_nlb ? var.vpc_config.private_subnets : []
9090

9191
extra_listeners = var.extra_nlb_listeners
92+
93+
enable_deletion_protection = var.enable_deletion_protection
9294
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,3 +773,9 @@ variable "mtls_enabled" {
773773
type = bool
774774
default = true
775775
}
776+
777+
variable "enable_deletion_protection" {
778+
description = "Whether to enable deletion protection on the Traefik NLB/ALB load balancers. Set to false before destroying the cluster."
779+
type = bool
780+
default = true
781+
}

0 commit comments

Comments
 (0)