Skip to content

Commit 7f78a6a

Browse files
authored
đź‘” feature: Exposes the function_assoication block of the distribution (#10)
1 parent 82c4ad8 commit 7f78a6a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

‎aws-cloudfront.tf‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ resource "aws_cloudfront_distribution" "site" {
2424
allowed_methods = ["GET", "HEAD"]
2525
cached_methods = ["GET", "HEAD"]
2626
cache_policy_id = data.aws_cloudfront_cache_policy.default.id
27+
28+
dynamic "function_association" {
29+
for_each = var.function_associations
30+
content {
31+
event_type = function_association.value.event_type
32+
function_arn = function_association.value.function_arn
33+
}
34+
}
2735
}
2836

2937
restrictions {

‎variables.tf‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,13 @@ variable "extra_domain_prefixes" {
5555
description = "Prefixes for additional custom domains to be associated with the CloudFront distribution."
5656
nullable = false
5757
}
58+
59+
variable "function_associations" {
60+
type = set(object({
61+
event_type = string
62+
function_arn = string
63+
}))
64+
default = []
65+
description = "A config block that triggers a lambda function with specific actions (maximum 4)."
66+
nullable = false
67+
}

0 commit comments

Comments
 (0)