@@ -4,7 +4,7 @@ module "this_label" {
44 attributes = [" hosting" , var . site_name ]
55}
66module "bucket" {
7- source = " git::github.com/xoap-io/terraform-aws-storage-s3.git?ref=v0.1.0 "
7+ source = " git::github.com/xoap-io/terraform-aws-storage-s3.git?ref=v0.1.1 "
88 context = var. context
99 name = var. site_name
1010 website_enabled = true
@@ -49,6 +49,29 @@ resource "aws_cloudfront_origin_request_policy" "this" {
4949 }
5050 query_strings_config {
5151 query_string_behavior = " all"
52+
53+ }
54+
55+ }
56+ resource "aws_cloudfront_response_headers_policy" "this" {
57+ name = module. this_label . id
58+
59+ cors_config {
60+ access_control_allow_credentials = false
61+
62+ access_control_allow_headers {
63+ items = var. cors_allowed_headers
64+ }
65+
66+ access_control_allow_methods {
67+ items = concat (var. cors_allowed_methods , [" OPTIONS" ])
68+ }
69+
70+ access_control_allow_origins {
71+ items = var. cors_allowed_origins
72+ }
73+
74+ origin_override = true
5275 }
5376}
5477# tfsec:ignore:AWS045
@@ -77,16 +100,14 @@ resource "aws_cloudfront_distribution" "this" {
77100 default_root_object = var. default_root_object
78101 aliases = var. cloudfront_aliases
79102 default_cache_behavior {
80- allowed_methods = var. allowed_methods
81- cached_methods = var. cached_methods
82- target_origin_id = var. s3_origin_id
83- compress = true
84- cache_policy_id = aws_cloudfront_cache_policy. this . id
85- origin_request_policy_id = aws_cloudfront_origin_request_policy. this . id
86- viewer_protocol_policy = var. viewer_protocol_policy
87- min_ttl = var. cf_min_ttl
88- max_ttl = var. cf_max_ttl
89- default_ttl = var. cf_default_ttl
103+ allowed_methods = var. allowed_methods
104+ cached_methods = var. cached_methods
105+ target_origin_id = var. s3_origin_id
106+ compress = true
107+ cache_policy_id = aws_cloudfront_cache_policy. this . id
108+ origin_request_policy_id = aws_cloudfront_origin_request_policy. this . id
109+ viewer_protocol_policy = var. viewer_protocol_policy
110+ response_headers_policy_id = aws_cloudfront_response_headers_policy. this . id
90111 }
91112 price_class = var. cf_price_class
92113 viewer_certificate {
0 commit comments