-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacm.tf
35 lines (30 loc) · 959 Bytes
/
acm.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
# Create a Domain ACM
resource "aws_acm_certificate" "certificate" {
domain_name = "*.${var.domain}"
validation_method = "DNS"
key_algorithm = "RSA_2048"
tags = local.common_tags
lifecycle {
create_before_destroy = true
}
}
#############################################################
#############################################################
# Create a CNAME on Cloudflayr
data "cloudflare_zone" "site_domain" {
name = var.domain
}
resource "cloudflare_record" "add_domain" {
for_each = {
for cert in aws_acm_certificate.certificate.domain_validation_options : cert.domain_name => {
name = cert.resource_record_name
record = cert.resource_record_value
type = cert.resource_record_type
}
}
allow_overwrite = true
name = each.value.name
value = each.value.record
type = each.value.type
zone_id = data.cloudflare_zone.site_domain.zone_id
}