oscarhermoso / terraform-provider-binarylane

This is a Terraform provider for Binary Lane, for reliable & affordable Australian VPS hosting
https://registry.terraform.io/providers/oscarhermoso/binarylane/latest
MIT License
9 stars 0 forks source link

Import server doesn't set public_ipv4_count #42

Closed timwsuqld closed 1 week ago

timwsuqld commented 2 weeks ago

Thanks so much for this provider!! I've been waiting for someone who can actually code this to make it happen, and was almost ready to give up and use another VPS provider.

Trying it out with an existing server resource via import, and it tries to update the public_ipv4_count which errors the API.

resource "binarylane_server" "uptime" {
  name              = "uptime"
  region            = "bne"
  image             = "ubuntu-22.04"
  size              = "std-min"
  public_ipv4_count = 1
}

Run the import terraform import binarylane_server.uptime uptime

Plan shows

  # binarylane_server.uptime will be updated in-place
  ~ resource "binarylane_server" "uptime" {
        id                        = 355186
        name                      = "uptime"
      ~ public_ipv4_addresses     = [
            "XX.XX.XX.XX",
          + null,
        ]
      + public_ipv4_count         = 1
        # (8 unchanged attributes hidden)
    }

Attempting to apply this gives:

│ Received 400 Bad Request resizing server: server_id=355186. Details: {"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors
│ occurred","status":400,"errors":{"":["This would result in no effective size change."]},"message":"This would result in no effective size change."}

terraform state show binarylane_server.uptime doesn't show the public_ipv4_count in the state.

# binarylane_server.uptime:
resource "binarylane_server" "uptime" {
    backups                   = false
    id                        = 355186
    image                     = "ubuntu-22.04"
    name                      = "uptime"
    password_change_supported = true
    permalink                 = "XX"
    port_blocking             = true
    private_ipv4_addresses    = [
        "172.21.2.XX",
    ]
    public_ipv4_addresses     = [
        "XX.XX.XX.XX",
    ]
    region                    = "bne"
    size                      = "std-min"
}
oscarhermoso commented 1 week ago

Hey @timwsuqld, thanks for the bug report.

I found the issue and it should be fixed in v0.8.1 of the provider, which will be released soon.