-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
53 lines (44 loc) · 1.28 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
resource "aws_lb" "my-website" {
name = "${element(split(".", var.zone_name ),0)}-www"
load_balancer_type = "application"
internal = false
idle_timeout = 400
subnets = "${var.subnets}"
security_groups = "${var.securitygroups}"
enable_http2 = true
}
resource "aws_lb_listener" "my_website_https" {
load_balancer_arn = "${aws_lb.my-website.arn}"
port = "443"
protocol = "HTTPS"
ssl_policy = "ELBSecurityPolicy-2015-05"
certificate_arn = "${var.cert_arn}"
default_action {
type = "redirect"
redirect {
protocol = "HTTPS"
status_code = "HTTP_301"
host = "www.#{host}"
path = "/#{path}"
query = "#{query}"
}
# target_group_arn = "${aws_lb_target_group.my_website_http.arn}"
}
}
resource "aws_lb_listener" "my_website_http" {
load_balancer_arn = "${aws_lb.my-website.arn}"
port = "80"
protocol = "HTTP"
default_action {
type = "redirect"
# target_group_arn = "${aws_lb_target_group.my_website_http.arn}"
redirect {
port = "443"
protocol = "HTTPS"
status_code = "HTTP_301"
host = "#{host}"
path = "/#{path}"
query = "#{query}"
}
}
}