Skip to content

Instantly share code, notes, and snippets.

@lawliet89
Last active September 3, 2018 04:46
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 lawliet89/d1b1fab79da782413b4b1d0d5b6d3c44 to your computer and use it in GitHub Desktop.
Save lawliet89/d1b1fab79da782413b4b1d0d5b6d3c44 to your computer and use it in GitHub Desktop.
Terraform Demo Snippet
resource "aws_lb_listener_rule" "client" {
listener_arn = "${aws_lb_listener.https.arn}"
priority = 100
action {
type = "forward"
target_group_arn = "${aws_lb_target_group.client.arn}"
}
condition {
field = "host-header"
values = ["${aws_route53_record.domain.fqdn}"]
}
}
resource "aws_lb_target_group" "client" {
name = "${var.lb_name}-client"
port = "${local.client_port}"
protocol = "HTTP"
vpc_id = "${var.vpc_id}"
tags = "${merge(var.tags, map("Name", "${var.lb_name}-client"))}"
stickiness {
type = "lb_cookie"
}
health_check {
path = "/"
protocol = "HTTP"
port = "${local.client_port}"
}
}
resource "aws_autoscaling_attachment" "client" {
alb_target_group_arn = "${aws_lb_target_group.client.arn}"
autoscaling_group_name = "${aws_autoscaling_group.client.id}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment