-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
88 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Register a new domain | ||
resource "aws_route53domains_registered_domain" "public" { | ||
domain_name = var.domain_name | ||
|
||
# Enable auto-renewal | ||
auto_renew = false | ||
|
||
# Enable privacy protection | ||
admin_privacy = true | ||
registrant_privacy = true | ||
tech_privacy = true | ||
|
||
name_server { | ||
name = aws_route53_zone.public.name_servers[0] | ||
} | ||
|
||
name_server { | ||
name = aws_route53_zone.public.name_servers[1] | ||
} | ||
} | ||
|
||
# Create a Route53 hosted zone for the domain | ||
resource "aws_route53_zone" "public" { | ||
name = var.domain_name | ||
} | ||
|
||
# Create an ACM certificate for the domain | ||
resource "aws_acm_certificate" "public" { | ||
domain_name = var.domain_name | ||
validation_method = "DNS" | ||
|
||
lifecycle { | ||
create_before_destroy = true | ||
} | ||
} | ||
|
||
# Create DNS records for ACM certificate validation | ||
resource "aws_route53_record" "cert_validation" { | ||
for_each = { | ||
for dvo in aws_acm_certificate.public.domain_validation_options : dvo.domain_name => { | ||
name = dvo.resource_record_name | ||
record = dvo.resource_record_value | ||
type = dvo.resource_record_type | ||
} | ||
} | ||
|
||
allow_overwrite = true | ||
name = each.value.name | ||
records = [each.value.record] | ||
ttl = 60 | ||
type = each.value.type | ||
zone_id = aws_route53_zone.public.zone_id | ||
} | ||
|
||
# Wait for certificate validation to complete | ||
resource "aws_acm_certificate_validation" "public" { | ||
certificate_arn = aws_acm_certificate.public.arn | ||
validation_record_fqdns = [for record in aws_route53_record.cert_validation : record.fqdn] | ||
} | ||
|
||
# Create DNS record for the load balancer | ||
resource "aws_route53_record" "lb" { | ||
zone_id = aws_route53_zone.public.zone_id | ||
name = var.domain_name | ||
type = "A" | ||
|
||
alias { | ||
name = module.xmtpd_api.load_balancer_address | ||
zone_id = module.xmtpd_api.load_balancer_zone_id | ||
evaluate_target_health = true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|