-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudfront.tf
46 lines (39 loc) · 1.4 KB
/
cloudfront.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
resource "aws_cloudfront_origin_access_control" "this" {
name = var.domain_name
origin_access_control_origin_type = "s3"
signing_behavior = "always"
signing_protocol = "sigv4"
}
resource "aws_cloudfront_distribution" "this" {
enabled = true
is_ipv6_enabled = true
aliases = [var.domain_name, "www.${var.domain_name}"]
price_class = "PriceClass_100"
default_root_object = "index.html"
origin {
domain_name = aws_s3_bucket.website.bucket_domain_name
origin_id = aws_s3_bucket.website.id
origin_access_control_id = aws_cloudfront_origin_access_control.this.id
}
viewer_certificate {
cloudfront_default_certificate = false
acm_certificate_arn = aws_acm_certificate.this.arn
minimum_protocol_version = "TLSv1.2_2021"
ssl_support_method = "sni-only"
}
restrictions {
geo_restriction {
restriction_type = "none"
locations = []
}
}
default_cache_behavior {
cache_policy_id = "658327ea-f89d-4fab-a63d-7e88639e58f6"
viewer_protocol_policy = "redirect-to-https"
compress = true
allowed_methods = ["GET", "HEAD", "OPTIONS"]
cached_methods = ["GET", "HEAD"]
target_origin_id = aws_s3_bucket.website.id
}
tags = var.tags
}