-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCloudFront.tf
More file actions
73 lines (58 loc) · 1.85 KB
/
CloudFront.tf
File metadata and controls
73 lines (58 loc) · 1.85 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
resource "aws_cloudfront_distribution" "m" {
origin {
domain_name = aws_s3_bucket.b.bucket_regional_domain_name
origin_id = "MW-CloudResume-CloudFront-Origin"
s3_origin_config {
origin_access_identity = aws_cloudfront_origin_access_identity.m.cloudfront_access_identity_path
}
}
enabled = true
is_ipv6_enabled = true
default_root_object = "index.html"
aliases = [
"${var.R53DomainName}",
"www.${var.R53DomainName}",
]
default_cache_behavior {
# CachingDisabled managed policy.
cache_policy_id = "4135ea2d-6df8-44a3-9df3-4b5a84be39ad"
allowed_methods = ["GET", "HEAD", "OPTIONS"]
cached_methods = ["GET", "HEAD"]
target_origin_id = "MW-CloudResume-CloudFront-Origin"
viewer_protocol_policy = "redirect-to-https"
}
price_class = "PriceClass_100"
restrictions {
geo_restriction {
restriction_type = "whitelist"
locations = ["AU", "US"]
}
}
viewer_certificate {
acm_certificate_arn = aws_acm_certificate.m.arn
ssl_support_method = "sni-only"
}
}
resource "aws_cloudfront_origin_access_identity" "m" {
comment = "Used for MW CloudFront Origin Access Identity."
}
resource "aws_route53_record" "m-cf-www" {
zone_id = data.aws_route53_zone.m.zone_id
name = "www.${var.R53DomainName}"
type = "A"
alias {
name = aws_cloudfront_distribution.m.domain_name
zone_id = aws_cloudfront_distribution.m.hosted_zone_id
evaluate_target_health = false
}
}
resource "aws_route53_record" "m-cf" {
zone_id = data.aws_route53_zone.m.zone_id
name = var.R53DomainName
type = "A"
alias {
name = aws_cloudfront_distribution.m.domain_name
zone_id = aws_cloudfront_distribution.m.hosted_zone_id
evaluate_target_health = false
}
}