IBM-Cloud / terraform-provider-ibm

https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs
Mozilla Public License 2.0
341 stars 670 forks source link

load balancer documentation fixes #3119

Closed powellquiring closed 2 years ago

powellquiring commented 3 years ago

https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/is_lb_listener and other ibm_islb* resources

resource "ibm_is_lb_pool" "webapptier-lb-pool" {
  lb                 = "8898e627-f61f-4ac8-be85-9db9d8bfd345"

Here is a more full example that could be used as a starting point. If this example is not included, then a link to some additional documentation that has this example will be needed.

resource "ibm_is_lb" "front" {
  name           = "${local.name}-front"
  subnets        = [for subnet in ibm_is_subnet.front : subnet.id]
  type           = "public"
  resource_group = local.resource_group
}
resource "ibm_is_lb_pool" "front" {
  lb                  = ibm_is_lb.front.id
  name                = "front"
  protocol            = "http"
  algorithm           = "round_robin"
  health_delay        = "5"
  health_retries      = "2"
  health_timeout      = "2"
  health_type         = "http"
  health_monitor_url  = "/health"
  health_monitor_port = "8000"
}
resource "ibm_is_lb_listener" "front" {
  lb           = ibm_is_lb.front.id
  port         = "8000"
  protocol     = "http"
  default_pool = ibm_is_lb_pool.front.id
}
resource "ibm_is_lb_pool_member" "front" {
  for_each       = ibm_is_instance.front
  lb             = ibm_is_lb.front.id
  pool           = element(split("/", ibm_is_lb_pool.front.id), 1)
  port           = "8000"
  target_address = each.value.primary_network_interface[0].primary_ipv4_address
}
output "lb_front" {
  value = "http://${ibm_is_lb.front.hostname}:8000"
}

You can see a full example here: https://github.ibm.com/portfolio-solutions/scenario-3tier

Notice how aws https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener uses cut downs. For us this would be:

resource "ibm_is_lb" "front" {
...
}
resource "ibm_is_lb_pool" "front" {
  lb                  = ibm_is_lb.front.id
...
}
resource "ibm_is_lb_listener" "front" {
  lb           = ibm_is_lb.front.id
  port         = "8000"
  protocol     = "http"
  default_pool = ibm_is_lb_pool.front.id
}

See: https://ibm-cloudplatform.slack.com/archives/C4YHGMBC7/p1631889177422900

astha-jain commented 3 years ago

@deepaksibm Could you please check?

geethasathyamurthy commented 2 years ago

@astha-jain , @deepaksibm

Could you please update the Terraform documentation with the dynamic attributes in the examples?

Regards, Geetha

astha-jain commented 2 years ago

Merged #3479

hkantare commented 2 years ago

Fixed in latest docs