Skip to content

Instantly share code, notes, and snippets.

@martinrusev
Created September 13, 2017 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinrusev/bd2e3b481a587b34361e52ae9e91da7d to your computer and use it in GitHub Desktop.
Save martinrusev/bd2e3b481a587b34361e52ae9e91da7d to your computer and use it in GitHub Desktop.
alb_example.tf
resource "aws_alb" "alb_grafana" {
name = "alb-energy-grafana"
internal = true
security_groups = ["${aws_security_group.sec_energy_grafana_elb.id}"]
subnets = ["${var.SUBNETS}"]
tags {
Name = "alb-energy-grafana"
Owner = "${var.OWNER}"
Creator = "${var.OWNER}"
Product = "Energy"
CostCenter = "Energy"
}
}
resource "aws_alb_listener" "alb_grafana_listener" {
load_balancer_arn = "${aws_alb.alb_grafana.arn}"
port = "443"
protocol = "HTTPS"
ssl_policy = "ELBSecurityPolicy-2016-08"
certificate_arn = "${data.aws_acm_certificate.grafana_ssl_cert.arn}"
default_action {
target_group_arn = "${aws_alb_target_group.alb_grafana_target_group.arn}"
type = "forward"
}
}
resource "aws_alb_target_group" "alb_grafana_target_group" {
name = "alb-energy-grafana-tg"
port = 3000
protocol = "HTTP"
vpc_id = "${var.VPC_ID}"
health_check {
healthy_threshold = 2
interval = 15
path = "/"
timeout = 10
unhealthy_threshold = 2
matcher = 302
}
}
resource "aws_alb_target_group_attachment" "alb_grafana_tg_instance" {
target_group_arn = "${aws_alb_target_group.alb_grafana_target_group.arn}"
target_id = "${aws_instance.grafana_server.id}"
port = 3000
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment