-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
75 lines (64 loc) · 1.86 KB
/
main.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
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
74
module "cdn" {
source = "terraform-aws-modules/cloudfront/aws"
comment = "My Location Based CDN"
enabled = true
is_ipv6_enabled = true
price_class = "PriceClass_All"
retain_on_delete = false
wait_for_deployment = false
default_root_object = "index.html"
create_origin_access_identity = true
origin_access_identities = {
s3_bucket_one = "My Location Based CloudFront can access"
}
origin = {
primary = {
domain_name = module.origin_bucket.s3_bucket_bucket_regional_domain_name
s3_origin_config = {
origin_access_identity = "s3_bucket_one"
}
custom_header = [
{ name: "primary", value: "True"}
]
},
failover = {
domain_name = module.origin_bucket.s3_bucket_bucket_regional_domain_name
s3_origin_config = {
origin_access_identity = "s3_bucket_one"
}
custom_header = [
{ name: "primary", value: "False"}
]
}
}
origin_group = {
my-origin-group = {
origin_id = "OriginGroup"
failover_status_codes = [400, 403, 404, 503]
primary_member_origin_id = "primary"
secondary_member_origin_id = "failover"
}
}
default_cache_behavior = {
target_origin_id = "OriginGroup"
viewer_protocol_policy = "allow-all"
allowed_methods = ["GET", "HEAD", "OPTIONS"]
cached_methods = ["GET", "HEAD"]
compress = true
query_string = true
min_ttl = 0
default_ttl = 86400
max_ttl = 31536000
use_forwarded_values = true
headers = ["CloudFront-Viewer-Country"]
lambda_function_association = {
origin-request = {
lambda_arn = aws_lambda_function.lambda.qualified_arn
include_body = false
}
}
}
viewer_certificate = {
cloudfront_default_certificate = true
}
}