Skip to content

Commit

Permalink
feat(aws): cloudfront add lambda function association
Browse files Browse the repository at this point in the history
  • Loading branch information
fredleger committed Mar 15, 2024
1 parent 84bc05a commit 6d9ee99
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions aws/cloudfront-distribution/cloudfront.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ resource "aws_cloudfront_distribution" "main" {
response_headers_policy_id = try(default_cache_behavior.value.response_headers_policy_id, null)
target_origin_id = try(default_cache_behavior.value.target_origin_id)
viewer_protocol_policy = try(default_cache_behavior.value.viewer_protocol_policy, "redirect-to-https")

# TODO: this is deprecated and we should check if origin_request_policy_id or cache_policy_id is set
dynamic "forwarded_values" {
for_each = try(default_cache_behavior.value.forwarded_values, null) != null ? [default_cache_behavior.value.forwarded_values] : []
Expand All @@ -65,6 +66,15 @@ resource "aws_cloudfront_distribution" "main" {
query_string = try(forwarded_values.value.query_string, false)
}
}

dynamic "lambda_function_association" {
for_each = length(default_cache_behavior.value.lambda_function_association) > 0 ? flatten([default_cache_behavior.value.lambda_function_association]) : []
content {
event_type = try(lambda_function_association.value.event_type, null)
include_body = try(lambda_function_association.value.include_body, null)
lambda_arn = try(lambda_function_association.value.lambda_arn, null)
}
}
}
}

Expand Down

0 comments on commit 6d9ee99

Please sign in to comment.