Skip to content

Commit c83e5cb

Browse files
author
rohit-ng
committed
feat: add module route-53-record
1 parent b56105b commit c83e5cb

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

modules/route-53-record/main.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
resource "aws_route53_record" "record" {
2+
for_each = toset(var.endpoints)
3+
zone_id = data.aws_route53_zone.zone.zone_id
4+
name = each.key
5+
type = "A"
6+
7+
alias {
8+
name = var.alb_dns_name
9+
zone_id = var.alb_zone_id
10+
evaluate_target_health = true
11+
}
12+
}
13+
14+
data "aws_acm_certificate" "base_domain_certificate" {
15+
domain = var.base_domain
16+
statuses = ["ISSUED"]
17+
most_recent = false
18+
}
19+
20+
data "aws_route53_zone" "zone" {
21+
name = var.base_domain
22+
}

modules/route-53-record/outputs.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
output "certificate_arn" {
2+
description = "ARN of the base domain certificate"
3+
value = data.aws_acm_certificate.base_domain_certificate.arn
4+
}
5+
6+
output "zone_id" {
7+
description = "ID of the Route 53 zone"
8+
value = data.aws_route53_zone.zone.zone_id
9+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
variable "base_domain" {
2+
description = "The base domain for the Route 53 zone"
3+
type = string
4+
}
5+
6+
variable "endpoints" {
7+
description = "A list of endpoints for which to create Route 53 records"
8+
type = list(string)
9+
}
10+
11+
variable "alb_dns_name" {
12+
description = "ALB DNS name"
13+
type = string
14+
}
15+
16+
variable "alb_zone_id" {
17+
description = "ALB zone ID"
18+
type = string
19+
}

0 commit comments

Comments
 (0)