linode / terraform-provider-linode

Terraform Linode provider
https://www.terraform.io/docs/providers/linode/
Mozilla Public License 2.0
202 stars 98 forks source link

Framework Migration: `linode_nodebalancer_node` Resource #1595

Closed zliang-akamai closed 2 weeks ago

zliang-akamai commented 1 month ago

📝 Description

This is to migrate linode_nodebalancer_node to be with Terraform Plugin Framework.

✔️ How to Test

make int-test PKG_NAME="linode/nbnode"
make int-test PKG_NAME="linode/nb"
make int-test PKG_NAME="linode/nbconfig"
resource "linode_instance" "foo" {
  count           = "2"
  label           = "web-${count.index + 1}"
  image           = "linode/ubuntu22.04"
  region          = "us-mia"
  type            = "g6-standard-1"
  authorized_keys = ["ssh-rsa AAAA...Gw== user@example.local"]
  root_pass       = "UNSAFE-PASSWORD!!"

  private_ip = true
}

resource "linode_nodebalancer" "foobar" {
  label                = "mynodebalancer"
  region               = "us-mia"
  client_conn_throttle = 20
}

resource "linode_nodebalancer_config" "foofig" {
  nodebalancer_id = linode_nodebalancer.foobar.id
  port            = 80
  protocol        = "http"
  check           = "http"
  check_path      = "/foo"
  check_attempts  = 3
  check_timeout   = 30
  stickiness      = "http_cookie"
  algorithm       = "source"
}

resource "linode_nodebalancer_node" "foonode" {
  count           = "2"
  nodebalancer_id = linode_nodebalancer.foobar.id
  config_id       = linode_nodebalancer_config.foofig.id
  address         = "${element(linode_instance.foo.*.private_ip_address, count.index)}:80"
  label           = "mynodebalancernode"
  weight          = 50

  lifecycle {
    // Tell Terraform to implicitly recreate the NodeBalancer node when
    // the target instance has been marked for recreation.
    // See: https://github.com/linode/terraform-provider-linode/issues/1224
    replace_triggered_by = [linode_instance.foo]
  }
}