forked from nextrevision/terraform-rancher-ha-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
elb_https.tf
61 lines (53 loc) · 1.95 KB
/
elb_https.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
54
55
56
57
58
59
60
61
#------------------------------------------#
# Elastic Load Balancer Configuration
#------------------------------------------#
resource "aws_elb" "rancher_ha_https" {
count = "${var.enable_https}"
name = "${var.name_prefix}-elb-https"
internal = "${var.internal_elb}"
listener {
instance_port = 8080
instance_protocol = "tcp"
lb_port = 443
lb_protocol = "ssl"
ssl_certificate_id = "${aws_iam_server_certificate.rancher_ha.arn}"
}
health_check {
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 3
target = "HTTP:8080/ping"
interval = 30
}
subnets = ["${aws_subnet.rancher_ha.*.id}"]
security_groups = ["${aws_security_group.rancher_ha_elb.id}"]
instances = ["${aws_instance.rancher_ha.*.id}"]
idle_timeout = 400
cross_zone_load_balancing = true
connection_draining = true
connection_draining_timeout = 400
tags {
Name = "${var.name_prefix}-elb-https"
}
}
resource "aws_iam_server_certificate" "rancher_ha" {
count = "${var.enable_https}"
name = "${var.name_prefix}-certificate"
certificate_body = "${file("${var.cert_body}")}"
private_key = "${file("${var.cert_private_key}")}"
certificate_chain = "${file("${var.cert_chain}")}"
}
resource "aws_proxy_protocol_policy" "rancher_ha_https_proxy_policy" {
count = "${var.enable_https}"
load_balancer = "${aws_elb.rancher_ha_https.name}"
instance_ports = ["81", "443", "8080"]
}
resource "aws_security_group_rule" "allow_https" {
count = "${var.enable_https}"
type = "ingress"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
security_group_id = "${aws_security_group.rancher_ha_elb.id}"
}