@@ -101,6 +101,16 @@ resource "aws_cloudfront_distribution" "app_cloudfront_distribution" {
101101 origin_ssl_protocols = [" TLSv1" , " TLSv1.1" , " TLSv1.2" ]
102102 }
103103 }
104+ origin {
105+ origin_id = " IAMLambdaFunction"
106+ domain_name = var. IAMLambdaHost
107+ custom_origin_config {
108+ http_port = 80
109+ https_port = 443
110+ origin_protocol_policy = " https-only"
111+ origin_ssl_protocols = [" TLSv1" , " TLSv1.1" , " TLSv1.2" ]
112+ }
113+ }
104114 default_root_object = " index.html"
105115 aliases = [var . CorePublicDomain ]
106116 enabled = true
@@ -127,6 +137,20 @@ resource "aws_cloudfront_distribution" "app_cloudfront_distribution" {
127137 restriction_type = " none"
128138 }
129139 }
140+ ordered_cache_behavior {
141+ path_pattern = " /api/v1/iam*"
142+ target_origin_id = " IAMLambdaFunction"
143+ viewer_protocol_policy = " redirect-to-https"
144+ allowed_methods = [" DELETE" , " GET" , " HEAD" , " OPTIONS" , " PATCH" , " POST" , " PUT" ]
145+ cached_methods = [" GET" , " HEAD" ]
146+ cache_policy_id = aws_cloudfront_cache_policy. headers_no_cookies . id
147+ origin_request_policy_id = " b689b0a8-53d0-40ab-baf2-68738e2966ac"
148+ compress = true
149+ function_association {
150+ event_type = " viewer-request"
151+ function_arn = aws_cloudfront_function. origin_key_injection . arn
152+ }
153+ }
130154 ordered_cache_behavior {
131155 path_pattern = " /api/v1/events*"
132156 target_origin_id = " LambdaFunction"
0 commit comments