-
Notifications
You must be signed in to change notification settings - Fork 6
/
domains.tf
54 lines (48 loc) · 1.74 KB
/
domains.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
resource "vercel_dns_record" "ar_io_root" {
count = var.use_vercel_domains ? 1 : 0
type = "CNAME"
domain = var.domain_name
name = var.subdomain_name
value = aws_cloudfront_distribution.ar_io_cf.domain_name
comment = "AR.IO gateway root (Terraform)"
}
resource "vercel_dns_record" "ar_io_sandbox" {
count = var.use_vercel_domains ? 1 : 0
type = "CNAME"
domain = var.domain_name
name = "*.${var.subdomain_name}"
value = aws_cloudfront_distribution.ar_io_cf.domain_name
comment = "AR.IO gateway sandbox (Terraform)"
}
resource "aws_acm_certificate" "cloudfront" {
provider = aws.us-east-1
domain_name = "${var.subdomain_name}.${var.domain_name}"
subject_alternative_names = [
"${var.subdomain_name}.${var.domain_name}",
"*.${var.subdomain_name}.${var.domain_name}"
]
validation_method = "DNS"
lifecycle {
create_before_destroy = true
}
}
resource "aws_acm_certificate" "alb" {
domain_name = "${var.subdomain_name}.${var.domain_name}"
subject_alternative_names = [
"${var.subdomain_name}.${var.domain_name}",
"*.${var.subdomain_name}.${var.domain_name}"
]
validation_method = "DNS"
lifecycle {
create_before_destroy = true
}
}
resource "vercel_dns_record" "dns_validation" {
count = var.use_vercel_domains ? 1 : 0
comment = "AR.IO - DNS validation (Terraform)"
domain = var.domain_name
name = trimsuffix(tolist(aws_acm_certificate.alb.domain_validation_options)[0].resource_record_name, ".${var.domain_name}.")
type = tolist(aws_acm_certificate.alb.domain_validation_options)[0].resource_record_type
value = tolist(aws_acm_certificate.alb.domain_validation_options)[0].resource_record_value
ttl = 60
}