forked from aws-samples/aws-waf-firewall-manager-terraform
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path5-optional-dev-cfront.tf_
107 lines (89 loc) · 2.66 KB
/
5-optional-dev-cfront.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#
# Copyright Amazon.com, Inc. and its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT
#
# Licensed under the MIT License. See the LICENSE accompanying this file
# for the specific language governing permissions and limitations under
# the License.
#
resource "aws_cloudfront_origin_access_identity" "dev_origin_access_identity" {
provider = aws.dev
comment = "waf poc"
}
resource "aws_cloudfront_distribution" "dev" {
provider = aws.dev
#default_root_object = var.default_root_object
enabled = true
is_ipv6_enabled = var.is_ipv6_enabled
price_class = "PriceClass_All"
retain_on_delete = var.retain_on_delete
wait_for_deployment = var.wait_for_deployment
#web_acl_id = var.web_acl_id
/* dynamic "logging_config" {
for_each = length(keys(var.logging_config)) == 0 ? [] : [var.logging_config]
content {
bucket = logging_config.value["bucket"]
prefix = lookup(logging_config.value, "prefix", null)
include_cookies = lookup(logging_config.value, "include_cookies", null)
}
} */
origin {
domain_name = "${aws_api_gateway_rest_api.apigw.id}.execute-api.eu-west-1.amazonaws.com"
origin_id = "apigw"
origin_path = "/dev"
custom_origin_config {
http_port = 80
https_port = 443
origin_protocol_policy = "https-only"
origin_ssl_protocols = ["TLSv1", "TLSv1.1"]
}
/* dynamic "custom_header" {
for_each = lookup(origin.value, "custom_header", [])
content {
name = custom_header.value.name
value = custom_header.value.value
}
} */
}
default_cache_behavior {
target_origin_id = "apigw"
viewer_protocol_policy = "https-only"
allowed_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
cached_methods = ["GET", "HEAD", "OPTIONS"]
compress = true
#field_level_encryption_id = lookup(i.value, "field_level_encryption_id", null)
min_ttl = 0
default_ttl = 3600
max_ttl = 86400
forwarded_values {
query_string = true
headers = ["Accept", "Referer", "Authorization", "Content-Type"]
cookies {
forward = "all"
}
}
}
viewer_certificate {
cloudfront_default_certificate = true
}
restrictions {
geo_restriction {
restriction_type = "none"
}
}
tags = merge(
{
"Name" = format("%s", "CloudFront ${var.environment}")
},
{
"Environment" = format("%s", var.environment)
},
local.cfront_tags,
local.common_tags,
)
lifecycle {
ignore_changes = [
web_acl_id,
]
}
}