Skip to content

Commit

Permalink
Merge pull request #10 from solutionDrive/enable-https-by-default
Browse files Browse the repository at this point in the history
Changes the port 80 listener to have a default action that redirects …
  • Loading branch information
Matthias Alt authored Dec 20, 2018
2 parents 42a322b + dcc3f2a commit a73644a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ application-cluster in different code bases!
1. LoadBalancer

Resources for a LoadBalancer (default: ApplicationLoadBalancer) with
1 Listener for Port 80
1 Listener for Port 80 (the default action is to redirect to https)
1 Listener for Port 443 (An AWS-certificate is mandatory for this at the moment)
1 Default Target Group (needed to define a listener)

Expand Down
9 changes: 7 additions & 2 deletions loadbalancer/loadbalancer.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ resource "aws_lb_listener" "loadbalancer_listener" {
protocol = "HTTP"

default_action {
target_group_arn = "${aws_lb_target_group.loadbalancer_default_target_group.arn}"
type = "forward"
type = "redirect"

redirect {
port = "443"
protocol = "HTTPS"
status_code = "HTTP_301"
}
}
}

Expand Down

0 comments on commit a73644a

Please sign in to comment.