Skip to content

Commit

Permalink
Merge pull request #6 from grupoboticario/set_web_acl_id
Browse files Browse the repository at this point in the history
Set web acl
  • Loading branch information
pjuniorlima authored Jun 29, 2021
2 parents a938625 + 20f4506 commit bba656d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions site-main/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ resource "aws_cloudfront_distribution" "website_cdn" {
enabled = true
price_class = var.price_class
http_version = "http2"
web_acl_id = var.web_acl_id != null ? var.web_acl_id : null

origin {
origin_id = var.create_bucket == true ? "origin-bucket-${aws_s3_bucket.website_bucket[0].id}" : "origin-bucket-${var.bucket_name}"
Expand Down
5 changes: 5 additions & 0 deletions site-main/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,9 @@ variable "cache_policy_id" {
variable "origin_request_policy_id" {
default = "88a5eaf4-2fd4-4709-b370-b4c650ea3fcf"
description = "Name of origin request policy previously created"
}

variable "web_acl_id" {
description = "ARN of WAF"
default = null
}
8 changes: 8 additions & 0 deletions site-redirect/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ resource "aws_cloudfront_distribution" "website_cdn" {
allowed_methods = ["GET", "HEAD", "DELETE", "OPTIONS", "PATCH", "POST", "PUT"]
cached_methods = ["GET", "HEAD"]

dynamic "lambda_function_association" {
for_each = var.enable_lambda_sec_headers == null ? [] : var.enable_lambda_sec_headers
content {
event_type = lambda_function_association.value.event_type
lambda_arn = lambda_function_association.value.lambda_arn
}
}

forwarded_values {
query_string = var.forward-query-string

Expand Down
10 changes: 10 additions & 0 deletions site-redirect/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,14 @@ variable "forward-query-string" {
type = bool
description = "Forward the query string to the origin"
default = true
}

variable "enable_lambda_sec_headers" {
type = list(object({
event_type = string
lambda_arn = string
}))
default = null

description = "Specifies the lambda function of security headers"
}

0 comments on commit bba656d

Please sign in to comment.