Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framework Migration: linode_nodebalancer_node Resource #1595

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

zliang-akamai
Copy link
Member

@zliang-akamai zliang-akamai commented Sep 24, 2024

📝 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]
  }
}

@zliang-akamai zliang-akamai added the improvement for improvements in existing functionality in the changelog. label Sep 24, 2024
@zliang-akamai zliang-akamai marked this pull request as ready for review September 24, 2024 22:35
@zliang-akamai zliang-akamai requested a review from a team as a code owner September 24, 2024 22:35
@zliang-akamai zliang-akamai requested review from jriddle-linode and yec-akamai and removed request for a team September 24, 2024 22:35
Copy link
Contributor

@yec-akamai yec-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, nice work!


// Add resource to TF states earlier to prevent
// dangling resources (resources created but not managed by TF)
AddNodeResource(ctx, *node, resp, plan)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, is preventing dangling resources in creation a new suggestion from Hashicorp? Looks like we didn't have this logic in other resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement for improvements in existing functionality in the changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants