diff --git a/generic/lightsail/main.tf b/generic/lightsail/main.tf index d93a71cd..813ebbd5 100644 --- a/generic/lightsail/main.tf +++ b/generic/lightsail/main.tf @@ -23,29 +23,25 @@ resource "aws_lightsail_container_service" "this" { # Domain settings data "aws_route53_zone" "this" { - count = var.domain ? 1 : 0 - name = var.domain_name + name = var.domain_name } locals { - url_no_protocol = replace(replace(aws_lightsail_container_service.this.url, "https://", ""), "//$/", "") - custom_domain_zone_id = var.domain ? data.aws_route53_zone.this[0].id : "" + url_no_protocol = replace(replace(aws_lightsail_container_service.this.url, "https://", ""), "//$/", "") } resource "aws_route53_record" "custom_domain" { - count = var.domain ? 1 : 0 name = var.subdomain_name type = "CNAME" records = [local.url_no_protocol] ttl = 300 - zone_id = local.custom_domain_zone_id + zone_id = data.aws_route53_zone.this.id } resource "aws_route53_record" "www_custom_domain" { - count = var.domain ? 1 : 0 name = "www.${var.subdomain_name}" type = "CNAME" records = [local.url_no_protocol] ttl = 300 - zone_id = local.custom_domain_zone_id + zone_id = data.aws_route53_zone.this.id } diff --git a/generic/lightsail/variables.tf b/generic/lightsail/variables.tf index 47900c5f..51d9bc1f 100644 --- a/generic/lightsail/variables.tf +++ b/generic/lightsail/variables.tf @@ -23,25 +23,17 @@ variable "private_registry_access" { } # Domain settings -variable "domain" { - description = "Whether to configure a public domain" - type = bool - default = false -} variable "certificate_name" { description = "Name of the validated certificate for SSL" type = string - default = "" } variable "domain_name" { description = "The name of the DNS region." type = string - default = "" } variable "subdomain_name" { description = "The domain name for the app." type = string - default = "" }