Skip to content

Instantly share code, notes, and snippets.

@brandonjbjelland
Last active March 23, 2018 04:07
Show Gist options
  • Save brandonjbjelland/83622c11acdae9e9b77bfe3290875578 to your computer and use it in GitHub Desktop.
Save brandonjbjelland/83622c11acdae9e9b77bfe3290875578 to your computer and use it in GitHub Desktop.
alb module main
resource "aws_lb_target_group" "main" {
name = "${lookup(var.target_groups[count.index], "name")}"
vpc_id = "${var.vpc_id}"
port = "${lookup(var.target_groups[count.index], "backend_port")}"
protocol = "${upper(lookup(var.target_groups[count.index], "backend_protocol"))}"
deregistration_delay = "${lookup(var.target_groups[count.index], "deregistration_delay", lookup(var.target_groups_defaults, "deregistration_delay"))}"
target_type = "${lookup(var.target_groups[count.index], "target_type", lookup(var.target_groups_defaults, "target_type"))}"
health_check {
interval = "${lookup(var.target_groups[count.index], "health_check_interval", lookup(var.target_groups_defaults, "health_check_interval"))}"
path = "${lookup(var.target_groups[count.index], "health_check_path", lookup(var.target_groups_defaults, "health_check_path"))}"
port = "${lookup(var.target_groups[count.index], "health_check_port", lookup(var.target_groups_defaults, "health_check_port"))}"
healthy_threshold = "${lookup(var.target_groups[count.index], "health_check_healthy_threshold", lookup(var.target_groups_defaults, "health_check_healthy_threshold"))}"
unhealthy_threshold = "${lookup(var.target_groups[count.index], "health_check_unhealthy_threshold", lookup(var.target_groups_defaults, "health_check_unhealthy_threshold"))}"
timeout = "${lookup(var.target_groups[count.index], "health_check_timeout", lookup(var.target_groups_defaults, "health_check_timeout"))}"
protocol = "${upper(lookup(var.target_groups[count.index], "healthcheck_protocol", lookup(var.target_groups[count.index], "backend_protocol")))}"
matcher = "${lookup(var.target_groups[count.index], "health_check_matcher", lookup(var.target_groups_defaults, "health_check_matcher"))}"
}
stickiness {
type = "lb_cookie"
cookie_duration = "${lookup(var.target_groups[count.index], "cookie_duration", lookup(var.target_groups_defaults, "cookie_duration"))}"
enabled = "${lookup(var.target_groups[count.index], "stickiness_enabled", lookup(var.target_groups_defaults, "stickiness_enabled"))}"
}
tags = "${merge(var.tags, map("Name", lookup(var.target_groups[count.index], "name")))}"
count = "${var.target_groups_count}"
depends_on = ["aws_lb.application"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment