Closed raisedadead closed 7 months ago
@raisedadead thanks for opening this issue.
We are looking to add a NodeBalancers data source which will allow you to filter by label and tag as you've described. WIP PR for reference.
Achieving what you want for NodeBalancer Configs is more complex, but we are looking into this as well.
Alternatively – @raisedadead in your "Potential Terraform Configuration" you are using the linode_nodebalancer_node
resources, but not the linode_nodebalancer
or linode_nodebalancer_config
resources.
Can you manage your NodeBalancers and NB Configs via Terraform as well? Then you wouldn't need to use data sources; you could reference the resource itself. Something like this:
resource "linode_nodebalancer" "example_nb_proxy" {
label = "my-label"
region = "us-east"
}
resource "linode_nodebalancer_config" "example_nb_pxy_config__port_80" {
port = 80
nodebalancer_id = linode_nodebalancer.example_nb_proxy.id
protocol = "http"
algorithm = "roundrobin"
stickiness = "none"
check = "http_body"
check_interval = "90"
check_timeout = "10"
check_attempts = "3"
check_path = "/test/"
check_body = "it works"
check_passive = true
}
resource "linode_nodebalancer_node" "example_nb_pxy_nodes__port_80" {
count = local.pxy_node_count
nodebalancer_id = linode_nodebalancer.example_nb_proxy.id
config_id = linode_nodebalancer_config.example_nb_pxy_config__port_80.id
address = "${linode_instance.example_pxy[count.index].private_ip_address}:80"
label = "example-node-pxy-80-${count.index}"
}
Are more complete example can be found here.
Hi @jcallahan-akamai
Thanks for your response. I'm looking at your PR, which should solve our needs.
Achieving what you want for NodeBalancer Configs is more complex, but we are looking into this as well.
If it helps, it should be fine if we could query the configs from the NB data source as an attribute. The main thing is to find the NB data source.
Can you manage your NodeBalancers and NB Configs via Terraform as well?
We do, actually!
Unfortunately, we must keep the NB Terraform configs separate from the nodes for the business logic.
For context, the NBs will almost never change. They are our primary origins and entry points. The idea is to swap out nodes (via separate TF Configs) for a blue-green-style deployment.
We avoid accidental changes by keeping them separate (and using NBs as data sources).
We are fine with the "hardcoding" right now - it gets the job done and will update the code whenever the PR makes the cut.
Thanks again.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
Hi @jcallahan-akamai @lgarber-akamai - Do you want to keep this open? We would still want this. Is there anything we can do to help?
Hi @raisedadead,
The PR (https://github.com/linode/terraform-provider-linode/pull/955) by @jcallahan-akamai has been merged and released in version v2.6.0
. Can you try to upgrade the Linode Terraform Provider and let us know the result?
So - I gave this a cursory look, and it seems that the data source for linode_nodebalancers
has been added and will suffice first part of our needs. That is I believe we can now:
data "linode_nodebalancers" "example_nbs" {
filter {
name = "label"
values = ["example-nb"]
}
}
data "linode_nodebalancer_config" "example_nb_config" {
id = 999999 # TODO: Find a way to get this ID dynamically
nodebalancer_id = data.linode_nodebalancers.example_nbs.nodebalancers[0].id
}
We would still want a data source to filter on linode_nodebalancer_config
s, too, and from John's comments, it is more involving and may be in the works.
Consider splitting this into a separate issue if you like for filtering on the configs.
Hey @raisedadead, we've added a task to create a filterable linode_nodebalancer_configs
datasource to our backlog. We'll keep this issue open until we can work on it.
Hi @raisedadead, yesterday we released a new version v2.12.0 which supports filtering on linode_nodebalancer_configs
. Please let us know if it works for your and reach out for any issue!
Sure - let me get back to you all after we upgrade our code to use this version. Thanks a lot!
We have been using this, and works like a charm. Thanks getting these out!
Description
The data resource for NodeBalancer and NodeBalancer Config is tedious to manage:
The IDs:
XXXXXX
,YYYYYY
, andZZZZZZ
are resource IDs that we need to find using either the Linode CLI, Linode API, or some other method before using it in the code above. This is less than ideal.Please include a query by label OR tags to better manage this.
New or Affected Terraform Resources
linode_nodebalancer linode_nodebalancer_config
Potential Terraform Configuration