Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow lambda_function_associations to be set #78

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,16 @@ variable "cloudfront_function_association" {
default = []
}

variable "cloudfront_lambda_function_association" {
jnonino marked this conversation as resolved.
Show resolved Hide resolved
description = "(Optional - up to 2 per distribution) List containing information to associate a CF lambda_function to cloudfront. The first field is `event_type` of the CF function associated with default cache behavior, it can be origin-request or origin-response"
type = list(object({
event_type = string
lambda_arn = string
include_body = bool
}))
default = []
}

variable "cloudfront_custom_error_responses" {
description = "A list of custom error responses"
type = list(object({
Expand Down
8 changes: 8 additions & 0 deletions website.tf
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ resource "aws_cloudfront_distribution" "website" {
function_arn = function_association.value.function_arn
}
}
dynamic "lambda_function_association" {
for_each = var.cloudfront_lambda_function_association
content {
event_type = lambda_function_association.value.event_type
lambda_arn = lambda_function_association.value.lambda_arn
include_body = lambda_function_association.value.include_body
}
}
}

dynamic "custom_error_response" {
Expand Down
Loading