File tree 4 files changed +31
-6
lines changed 4 files changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -3,4 +3,9 @@ resource "aws_acm_certificate" "cloudfront_cert" {
3
3
validation_method = " DNS"
4
4
tags = var. tags
5
5
provider = aws. acm
6
+ }
7
+
8
+ resource "aws_acm_certificate_validation" "cert_validation" {
9
+ certificate_arn = aws_acm_certificate. cloudfront_cert . arn
10
+ validation_record_fqdns = [for record in data . hosted_zone : record . fqdn ]
6
11
}
Original file line number Diff line number Diff line change @@ -60,6 +60,10 @@ data "aws_iam_policy_document" "deploy_web" {
60
60
}
61
61
}
62
62
63
+ data "aws_route53_zone" "hosted_zone" {
64
+ name = var. domain_name
65
+ }
66
+
63
67
data "aws_iam_openid_connect_provider" "github" {
64
68
url = " https://token.actions.githubusercontent.com"
65
69
}
Original file line number Diff line number Diff line change
1
+ # ############################################
2
+ # Validation for the ACM cert
3
+ # ############################################
4
+
5
+ resource "aws_route53_record" "acm_records" {
6
+ for_each = {
7
+ for dvo in aws_acm_certificate . aws_acm_certificate . cloudfront_cert . domain_validation_options : dvo . domain_name => {
8
+ name = dvo.resource_record_name
9
+ record = dvo.resource_record_value
10
+ type = dvo.resource_record_type
11
+ }
12
+ }
13
+
14
+ allow_overwrite = true
15
+ name = each. value . name
16
+ records = [each . value . record ]
17
+ ttl = 60
18
+ type = each. value . type
19
+ zone_id = data. aws_route53_zone . hosted_zone . zone_id
20
+ }
21
+
1
22
# ############################################
2
23
# Setup the A record for your custom domain
3
24
# ############################################
4
25
5
26
resource "aws_route53_record" "static_site_a_record" {
6
- zone_id = var . hosted_zone_id
27
+ zone_id = data . aws_route53_zone . hosted_zone . zone_id
7
28
name = var. domain_name
8
29
type = " A"
9
30
Original file line number Diff line number Diff line change @@ -3,11 +3,6 @@ variable "bucket_name" {
3
3
description = " The name of the bucket which will hold your static site"
4
4
}
5
5
6
- variable "hosted_zone_id" {
7
- type = string
8
- description = " The hosted zone ID to attach the A record for your custom domain"
9
- }
10
-
11
6
variable "domain_name" {
12
7
type = string
13
8
description = " The custom domain for your CloudFront distribution"
You can’t perform that action at this time.
0 commit comments