diff --git a/modules/worker/main.tf b/modules/worker/main.tf index ac14b10..9c72d2a 100644 --- a/modules/worker/main.tf +++ b/modules/worker/main.tf @@ -247,17 +247,14 @@ resource "aws_lb_listener" "public_http" { } /* Route53 hosted zone */ -resource "aws_route53_zone" "api" { - name = "${var.environment == "production" ? "" : "${var.environment}."}${var.api_hostname}" - - lifecycle { - prevent_destroy = true - } +data "aws_route53_zone" "api" { + name = "${var.api_hostname}" + depends_on = ["aws_route53_zone.api"] } resource "aws_route53_record" "lb" { - zone_id = "${aws_route53_zone.api.zone_id}" - name = "${aws_route53_zone.api.name}" + zone_id = "${data.aws_route53_zone.api.zone_id}" + name = "${var.environment == "production" ? "" : "${var.environment}."}${var.api_hostname}" type = "A" alias {