Skip to content

Commit

Permalink
Merge pull request #16 from joepurnell1/feat/http-redirect
Browse files Browse the repository at this point in the history
Add http -> https redirect
  • Loading branch information
Joe Purnell authored Oct 17, 2019
2 parents 7cce6ed + 7802649 commit 32476b5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
30 changes: 30 additions & 0 deletions lb-http.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

variable "http_port" {
default = "80"
}

resource "aws_alb_listener" "redirect_http_to_https" {
load_balancer_arn = aws_alb.main.id
port = var.http_port
protocol = "HTTP"

default_action {
type = "redirect"

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

resource "aws_security_group_rule" "ingress_lb_http" {
type = "ingress"
description = "HTTP"
from_port = var.http_port
to_port = var.http_port
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
security_group_id = aws_security_group.nsg_lb.id
}
1 change: 0 additions & 1 deletion lb-https.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ resource "aws_security_group_rule" "ingress_lb_https" {
cidr_blocks = ["0.0.0.0/0"]
security_group_id = aws_security_group.nsg_lb.id
}

0 comments on commit 32476b5

Please sign in to comment.