File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,33 @@ resource "aws_lb_listener" "alb_listener_http" {
5656 }
5757}
5858
59+ resource "aws_lb_listener_rule" "http_to_https_redirect" {
60+ count = var. certificate_arn != null ? 1 : 0
61+
62+ listener_arn = aws_lb_listener. alb_listener_http . arn
63+ priority = 50
64+
65+ action {
66+ type = " redirect"
67+ redirect {
68+ port = " 443"
69+ protocol = " HTTPS"
70+ status_code = " HTTP_301"
71+ host = " #{host}"
72+ path = " /#{path}"
73+ query = " #{query}"
74+ }
75+ }
76+ condition {
77+ path_pattern {
78+ values = [" /*" ]
79+ }
80+ }
81+ }
82+
5983resource "aws_lb_listener_rule" "app_http_forward" {
84+ count = var. certificate_arn == null ? 1 : 0
85+
6086 listener_arn = aws_lb_listener. alb_listener_http . arn
6187 priority = 100
6288
You can’t perform that action at this time.
0 commit comments