Skip to content

feat: Support http respond headers for ALB listeners #398

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

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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,13 @@ See [patterns.md](https://github.com/terraform-aws-modules/terraform-aws-alb/blo
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.82 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.84 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.82 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.84 |

## Modules

Expand Down
25 changes: 25 additions & 0 deletions examples/complete-alb/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,31 @@ module "alb" {
target_group_key = "ex-instance"
}
}

ex-response-headers = {
port = "443"
protocol = "HTTPS"
ssl_policy = "ELBSecurityPolicy-TLS13-1-2-Res-2021-06"
certificate_arn = module.acm.acm_certificate_arn

fixed_response = {
content_type = "text/plain"
message_body = "Fixed message"
status_code = "200"
}

routing_http_response_server_enabled = false
routing_http_response_strict_transport_security_header_value = "max-age=31536000; includeSubDomains; preload"
routing_http_response_access_control_allow_origin_header_value = "https://example.com"
routing_http_response_access_control_allow_methods_header_value = "TRACE,GET"
routing_http_response_access_control_allow_headers_header_value = "Accept-Language,Content-Language"
routing_http_response_access_control_allow_credentials_header_value = "true"
routing_http_response_access_control_expose_headers_header_value = "Cache-Control"
routing_http_response_access_control_max_age_header_value = 86400
routing_http_response_content_security_policy_header_value = "*"
routing_http_response_x_content_type_options_header_value = "nosniff"
routing_http_response_x_frame_options_header_value = "SAMEORIGIN"
}
}

target_groups = {
Expand Down
13 changes: 13 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,25 @@ resource "aws_lb_listener" "this" {
}
}

routing_http_response_server_enabled = try(each.value.routing_http_response_server_enabled, false)
routing_http_response_strict_transport_security_header_value = try(each.value.routing_http_response_strict_transport_security_header_value, null)
routing_http_response_access_control_allow_origin_header_value = try(each.value.routing_http_response_access_control_allow_origin_header_value, null)
routing_http_response_access_control_allow_methods_header_value = try(each.value.routing_http_response_access_control_allow_methods_header_value, null)
routing_http_response_access_control_allow_headers_header_value = try(each.value.routing_http_response_access_control_allow_headers_header_value, null)
routing_http_response_access_control_allow_credentials_header_value = try(each.value.routing_http_response_access_control_allow_credentials_header_value, null)
routing_http_response_access_control_expose_headers_header_value = try(each.value.routing_http_response_access_control_expose_headers_header_value, null)
routing_http_response_access_control_max_age_header_value = try(each.value.routing_http_response_access_control_max_age_header_value, null)
routing_http_response_content_security_policy_header_value = try(each.value.routing_http_response_content_security_policy_header_value, null)
routing_http_response_x_content_type_options_header_value = try(each.value.routing_http_response_x_content_type_options_header_value, null)
routing_http_response_x_frame_options_header_value = try(each.value.routing_http_response_x_frame_options_header_value, null)

load_balancer_arn = aws_lb.this[0].arn
port = try(each.value.port, var.default_port)
protocol = try(each.value.protocol, var.default_protocol)
ssl_policy = contains(["HTTPS", "TLS"], try(each.value.protocol, var.default_protocol)) ? try(each.value.ssl_policy, "ELBSecurityPolicy-TLS13-1-2-Res-2021-06") : try(each.value.ssl_policy, null)
tcp_idle_timeout_seconds = try(each.value.tcp_idle_timeout_seconds, null)
tags = merge(local.tags, try(each.value.tags, {}))

}

################################################################################
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.82"
version = ">= 5.84"
}
}
}
2 changes: 1 addition & 1 deletion wrappers/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.82"
version = ">= 5.84"
}
}
}