Skip to content

Commit

Permalink
fix: Prevent HostedZoneNotEmpty during terraform destroy (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
msvticket authored Jun 9, 2021
1 parent e33e95f commit 9d1d99a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ module "dns" {
tls_email = var.tls_email
enable_external_dns = var.enable_external_dns
create_and_configure_subdomain = var.create_and_configure_subdomain
force_destroy_subdomain = var.force_destroy_subdomain
enable_tls = var.enable_tls
production_letsencrypt = var.production_letsencrypt
manage_apex_domain = var.manage_apex_domain
Expand Down
1 change: 1 addition & 0 deletions modules/dns/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ data "aws_route53_zone" "apex_domain_zone" {
resource "aws_route53_zone" "subdomain_zone" {
count = var.create_and_configure_subdomain && var.manage_subdomain ? 1 : 0
name = join(".", [var.subdomain, var.apex_domain])
force_destroy = var.force_destroy_subdomain
}

resource "aws_route53_record" "subdomain_ns_delegation" {
Expand Down
6 changes: 6 additions & 0 deletions modules/dns/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ variable "create_and_configure_subdomain" {
default = false
}

variable "force_destroy_subdomain" {
description = "Flag to determine whether subdomain zone get forcefully destroyed. If set to false, empty the sub domain first in the aws Route 53 console, else terraform destroy will fail with HostedZoneNotEmpty error"
type = bool
default = false
}

variable "enable_tls" {
type = bool
default = false
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ variable "create_and_configure_subdomain" {
default = false
}

variable "force_destroy_subdomain" {
description = "Flag to determine whether subdomain zone get forcefully destroyed. If set to false, empty the sub domain first in the aws Route 53 console, else terraform destroy will fail with HostedZoneNotEmpty error"
type = bool
default = false
}

variable "enable_tls" {
description = "Flag to enable TLS in the final `jx-requirements.yml` file"
type = bool
Expand Down

0 comments on commit 9d1d99a

Please sign in to comment.