cloudamqp / terraform-provider-cloudamqp

Terraform Provider for CloudAMQP
https://registry.terraform.io/providers/cloudamqp/cloudamqp
Mozilla Public License 2.0
35 stars 39 forks source link

Add AZ ID to nodes data source #288

Closed laurodias closed 3 months ago

laurodias commented 3 months ago

Currently there are no resources or data sources that export nodes availability zones, except for the active_zones attribute by cloudamqp_privatelink_aws/cloudamqp_vpc_connect. However, the attribute doesn't get updated when an instance is resized until a next plan/apply.

As the console states that If you add more servers to this cluster you will need to go back to the AWS console, edit the endpoint and add the additional subnets, updating cloudamqp_nodes data source to be incremented with nodes availability zone IDs could be helpful to trigger aws_vpc_endpoint update. My use case is:

  1. Modify instance plan changing number of nodes
  2. Load modified instance data to get updated list of availability zone ids
  3. Get data from subnets in the same azs
  4. Update vpc endpoint with new list of subnets
{
  "id" = 0000
  "instance_id" = 1111
  "nodes" = tolist([
    {
      "additional_disk_size" = 0
      "configured" = true
      "disk_size" = 10
      "erlang_version" = "xx.x.x"
      "hipe" = false
      "hostname" = "node-01.rmq3.cloudamqp.com"
      "name" = "node-01"
      "rabbitmq_version" = "3.13.2"
      "running" = true
      "az" = "use1-az1"
    },
  ])
}

I think that could also be achieved if we had a cloudamqp_vpc_connect data source to be loaded after instance update.

tbroden84 commented 3 months ago

@laurodias See a problem with creating the cloudamqp_vpc_connect data source. Since it will not automatically reload when changes are done to the instance. One way to force all resources and data sources to read out the data from backend is to use terraform apply -refresh-only

Instead, added the availability_zone to the nodes data source. Each node will now display the availability zone ID. Also made sure the AZ got updated, after the instance update.

Created a new release v1.30.1 with availability_zone available for all nodes.

Closing the issue, feel free to re-open if there are any more questions.