Skip to content

Commit

Permalink
Add dynamic lambda (#6)
Browse files Browse the repository at this point in the history
* feat: Adding dynamic lambda function for icon directory

* fix: use correct cloudfront distro point

Co-authored-by: Jon Crain <jon.crain@unity3d.com>
  • Loading branch information
clburlison and joncrain committed Jul 28, 2022
1 parent 69eb0ef commit 2bdb376
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cloudfront.tf
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,12 @@ resource "aws_cloudfront_distribution" "munki_basic_auth" {
ordered_cache_behavior {
path_pattern = "/icons/*"

lambda_function_association {
event_type = "viewer-request"
lambda_arn = "${aws_lambda_function.basic_auth_lambda[0].arn}:${aws_lambda_function.basic_auth_lambda[0].version}"
dynamic "lambda_function_association" {
for_each = var.enable_icons_basic_auth ? ["true"] : []
content {
event_type = "viewer-request"
lambda_arn = "${aws_lambda_function.basic_auth_lambda[0].arn}:${aws_lambda_function.basic_auth_lambda[0].version}"
}
}

trusted_signers = var.cf_trusted_signers
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,9 @@ variable "icons_ordered_cache_behavior_max_ttl" {
default = 60
description = "The maximum amount of time (in seconds) that a icon object is in a CloudFront cache before CloudFront forwards another request to your origin to determine whether the object has been updated."
}

variable "enable_icons_basic_auth" {
type = bool
default = true
description = "When set to 'true' the resource will enable basic auth for icons/ subpath"
}

0 comments on commit 2bdb376

Please sign in to comment.