-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudfront.tf
More file actions
58 lines (51 loc) · 1.79 KB
/
cloudfront.tf
File metadata and controls
58 lines (51 loc) · 1.79 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
data "aws_acm_certificate" "default" {
provider = aws.us-east-1
domain = var.name
statuses = ["ISSUED"]
key_types = ["RSA_2048", "EC_prime256v1"]
most_recent = true
}
resource "aws_cloudfront_distribution" "default" {
origin {
domain_name = aws_s3_bucket.default.bucket_regional_domain_name
origin_id = aws_s3_bucket.default.bucket_regional_domain_name
origin_access_control_id = aws_cloudfront_origin_access_control.default.id
connection_attempts = 3
connection_timeout = 10
}
default_root_object = "index.html"
enabled = true
comment = "Console assets"
aliases = concat([var.name], var.aliases)
is_ipv6_enabled = true
price_class = "PriceClass_100"
tags = var.tags
default_cache_behavior {
allowed_methods = ["GET", "HEAD", "OPTIONS"]
cached_methods = ["GET", "HEAD"]
cache_policy_id = var.cloudfront_cached_policy_managed_optimized_id
target_origin_id = aws_s3_bucket.default.bucket_regional_domain_name
compress = true
viewer_protocol_policy = var.viewer_protocol_policy
}
restrictions {
geo_restriction {
restriction_type = "none"
}
}
viewer_certificate {
acm_certificate_arn = data.aws_acm_certificate.default.arn
minimum_protocol_version = "TLSv1.2_2021"
ssl_support_method = "sni-only"
}
lifecycle {
ignore_changes = []
}
}
resource "aws_cloudfront_origin_access_control" "default" {
name = var.name
description = "Allow access to ${var.name}-managed S3 bucket"
origin_access_control_origin_type = "s3"
signing_behavior = "always"
signing_protocol = "sigv4"
}