Skip to content

Commit c73e948

Browse files
committed
refactor(modules/route-53-record): code cleanup and simplify names
1 parent 32a58ce commit c73e948

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

modules/route-53-record/main.tf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
locals {
22
domain_parts = regexall("(.*\\.)?(.*\\..*)", var.domain)
3-
base_domain = length(local.domain_parts) > 0 && length(local.domain_parts[0]) > 1 ? local.domain_parts[0][1] : var.domain
3+
base_domain = (
4+
length(local.domain_parts) > 0 && length(local.domain_parts[0]) > 1 ?
5+
local.domain_parts[0][1] : var.domain)
46
}
57

6-
data "aws_acm_certificate" "domain" {
7-
domain = local.base_domain
8-
statuses = ["ISSUED"]
9-
most_recent = false
10-
}
8+
################################################################################
9+
# ACM Certificate
10+
################################################################################
1111

12-
data "aws_route53_zone" "zone" {
12+
data "aws_route53_zone" "base_domain" {
1313
name = local.base_domain
1414
}
1515

16-
resource "aws_route53_record" "record" {
17-
zone_id = data.aws_route53_zone.zone.zone_id
16+
resource "aws_route53_record" "this" {
17+
zone_id = data.aws_route53_zone.base_domain.zone_id
1818
name = var.domain
1919
type = "A"
2020

modules/route-53-record/outputs.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
output "certificate_arn" {
2-
description = "ARN of the base domain certificate"
3-
value = data.aws_acm_certificate.domain.arn
1+
################################################################################
2+
# Route53 Record
3+
################################################################################
4+
5+
output "id" {
6+
description = "Identifier of the Route53 Record"
7+
value = aws_route53_record.this.id
48
}
59

610
output "zone_id" {
711
description = "ID of the Route 53 zone"
8-
value = data.aws_route53_zone.zone.zone_id
12+
value = data.aws_route53_zone.base_domain.zone_id
913
}

modules/route-53-record/variables.tf

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1+
################################################################################
2+
# Route53 Record
3+
################################################################################
4+
15
variable "domain" {
2-
description = "Domain name"
6+
description = "(Required) Domain name for which the certificate should be issued."
37
type = string
8+
nullable = false
49
}
510

611
variable "alb_dns_name" {
7-
description = "ALB DNS name"
12+
description = "(Required) DNS domain name for a CloudFront distribution, S3 bucket, ELB, or another resource record set in this hosted zone."
813
type = string
14+
nullable = false
915
}
1016

1117
variable "alb_zone_id" {
12-
description = "ALB zone ID"
18+
description = "(Required) Hosted zone ID for a CloudFront distribution, S3 bucket, ELB, or Route 53 hosted zone."
1319
type = string
20+
nullable = false
1421
}

0 commit comments

Comments
 (0)