Terraform-provider-aws: Support for network load balancer

Created on 8 Sep 2017  ·  19Comments  ·  Source: hashicorp/terraform-provider-aws

AWS recently announced a new load balancer: the network load balancer

https://aws.amazon.com/blogs/aws/new-network-load-balancer-effortless-scaling-to-millions-of-requests-per-second/

Would be good to get support for this into this provider

enhancement

Most helpful comment

A basic example of a working tcp NLB, in case someone stumbles upon this thread:

resource "aws_lb" "testexternal" {
  name = "testLB"

  load_balancer_type               = "network"
  internal                         = false
  subnets                          = ["subnet-x", "subnet-y", "subnet-z"]
  enable_cross_zone_load_balancing = true
}

resource "aws_lb_listener" "testexternal" {
  load_balancer_arn = "${aws_lb.testexternal.arn}"
  protocol          = "TCP"
  port              = "22"


  default_action {
    target_group_arn = "${aws_lb_target_group.testexternal.arn}"
    type             = "forward"
  }
}


resource "aws_lb_target_group" "testexternal" {
  name     = "testexternal"
  protocol = "TCP"
  port     = 22
  vpc_id   = "vpc-w"


  health_check {
    healthy_threshold   = 3
    unhealthy_threshold = 3
    interval            = 10
    port                = 22
    protocol            = "TCP"
  }
}


resource "aws_lb_target_group_attachment" "testexternal" {
  target_group_arn = "${aws_lb_target_group.testexternal.arn}"
  target_id        = "i-12345678"
  port             = 22
}

All 19 comments

👍

+1

The ability to build a load-balancer from a number of EIP's is particularly interesting for services where moving to another IP-address causes huge operational headaches.

I had a feeling this was going to be requested right away.

NLB is amazing for supporting a static IP load balanced layer. Definitely looking forward to terraform support.

Reading over the docs looks like pretty much all the ALB stuff can be copied over and just renamed. Only need to add support for EIP and change the protocol options to TCP only on the target group. I will try to take a stab at this over the weekend but I have no idea how far I will make it.

I wondered whether this might be the case.

I also wondered whether it might be an idea to support both types with one code base, ie. have a type field to choose between alb and nlb?

I thought about that as well, but I think if we go that route would have to rename all the alb resources to something more generic and I'm not sure on the policy of breaking changes. I am in favor of just creating new resource type for nlb just in case they diverge more in the future but thats just my thoughts.

BTW @stack72 recently tweeted that he was looking at this.

+1

Excited to see this merged! Do we have an estimate of when a new release will be cut?

+++1 Looking to leverage nlb for multiple service offerings and this issue is blocking the adoption of terraform.

@ben-ms But it's not blocking anymore, it's merged and released.

@ben-ms It was released in v1.1.0 of the aws provider: https://github.com/terraform-providers/terraform-provider-aws/blob/master/CHANGELOG.md#110-october-16-2017

While merged, I believe there are still issues in #1838.
Somebody seems to be working on a ton of fixes in #1948 so I am patiently watching those 2 items. Cheers

The online documentation doesn't mention it anywhere as far as I could find. It would also be nice if the documentation showed what version a new feature like this was added so that we can determine whether or not we need to upgrade.

It will be really useful to have something like added in 1.2.0 in parameter or resource docs. Something like ansible has in modules, for example here http://docs.ansible.com/ansible/latest/archive_module.html

@robomon1 It's here:

https://www.terraform.io/docs/providers/aws/r/lb.html

With "load_balancer_type" = "network" or "application". I was able to get this working. The listeners must support HTTP(s).

A basic example of a working tcp NLB, in case someone stumbles upon this thread:

resource "aws_lb" "testexternal" {
  name = "testLB"

  load_balancer_type               = "network"
  internal                         = false
  subnets                          = ["subnet-x", "subnet-y", "subnet-z"]
  enable_cross_zone_load_balancing = true
}

resource "aws_lb_listener" "testexternal" {
  load_balancer_arn = "${aws_lb.testexternal.arn}"
  protocol          = "TCP"
  port              = "22"


  default_action {
    target_group_arn = "${aws_lb_target_group.testexternal.arn}"
    type             = "forward"
  }
}


resource "aws_lb_target_group" "testexternal" {
  name     = "testexternal"
  protocol = "TCP"
  port     = 22
  vpc_id   = "vpc-w"


  health_check {
    healthy_threshold   = 3
    unhealthy_threshold = 3
    interval            = 10
    port                = 22
    protocol            = "TCP"
  }
}


resource "aws_lb_target_group_attachment" "testexternal" {
  target_group_arn = "${aws_lb_target_group.testexternal.arn}"
  target_id        = "i-12345678"
  port             = 22
}

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

Was this page helpful?
0 / 5 - 0 ratings