Last active
February 28, 2017 20:34
-
-
Save pgporada/df740fc6f802c90be17fd949213c00b9 to your computer and use it in GitHub Desktop.
Terraform ELB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
other configs go here | |
*/ | |
resource "aws_security_group" "elb" { | |
name = "${var.env}-${var.tier}-elasticsearch-elb-sg" | |
vpc_id = "${var.vpc_id}" | |
description = "Allow http and https inbound traffic through the ELB." | |
tags { | |
TERRAFORM = "true" | |
ENV = "${var.env}" | |
TIER = "${var.tier}" | |
ROLE = "elasticsearch" | |
TYPE = "elastic" | |
} | |
ingress { | |
protocol = "tcp" | |
from_port = 80 | |
to_port = 80 | |
cidr_blocks = ["${var.vpc_cidr}","${var.peered_vpc_cidr}"] | |
} | |
ingress { | |
protocol = "tcp" | |
from_port = 443 | |
to_port = 443 | |
cidr_blocks = ["${var.vpc_cidr}","${var.peered_vpc_cidr}"] | |
} | |
ingress { | |
from_port = 8 | |
to_port = 0 | |
protocol = "icmp" | |
cidr_blocks = ["${var.vpc_cidr}","${var.peered_vpc_cidr}"] | |
} | |
egress { | |
protocol = -1 | |
from_port = 0 | |
to_port = 0 | |
cidr_blocks = ["0.0.0.0/0"] | |
} | |
} | |
resource "aws_elb" "elasticsearch" { | |
name = "${var.env}-${var.tier}-elasticsearch-elb" | |
connection_draining = true | |
connection_draining_timeout = 300 | |
cross_zone_load_balancing = true | |
internal = true | |
subnets = ["${split(",", var.ephemeral_subnet_ids)}"] | |
security_groups = ["${aws_security_group.elb.id}"] | |
access_logs { | |
bucket = "company-elb-access-logs" | |
interval = 60 | |
} | |
listener { | |
lb_port = 80 | |
lb_protocol = "http" | |
instance_port = 80 | |
instance_protocol = "http" | |
} | |
listener { | |
lb_port = 443 | |
lb_protocol = "https" | |
instance_port = 80 | |
instance_protocol = "http" | |
ssl_certificate_id = "${var.ssl_cert_arn}" | |
} | |
health_check { | |
healthy_threshold = 3 | |
unhealthy_threshold = 5 | |
timeout = 5 | |
target = "TCP:80" | |
interval = 30 | |
} | |
} | |
/* | |
other configs go here | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment