Skip to content

Commit

Permalink
Going back
Browse files Browse the repository at this point in the history
  • Loading branch information
jorge-cr-13 committed Dec 21, 2023
1 parent 9595829 commit 1f8fa91
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
12 changes: 4 additions & 8 deletions generic/lightsail/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
8 changes: 0 additions & 8 deletions generic/lightsail/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
}

0 comments on commit 1f8fa91

Please sign in to comment.