aequitas / terraform-provider-transip

Terraform provider to manage Transip resources
https://registry.terraform.io/providers/aequitas/transip/latest/docs
MIT License
35 stars 16 forks source link

Add ability to lock VPS #35

Open JoooostB opened 4 years ago

JoooostB commented 4 years ago

As of right now the provider has no support for setting the Customer Lock for a VPS (only for reading). In our workflow we like to set the Customer Lock directly after ordering, as we've had some issues with the front-end before where the wrong VPS got modified, upgraded or even deleted.

When ordering a VPS, TransIP's API does not support setting a Customer Lock on the VPS directly. However, when updating the VPS after you've ordered it, you'll be able to set the Lock. Hence why I added the Update function and changed line 236 to Update instead of Read the VPS, so the lock will be set if configured; even when the VPS was not created yet.

If you've got any feedback or suggestions, please let me know.

aequitas commented 4 years ago

I've tested this locally but the VPS does not seem to unlock with the update.

=== RUN   TestAccTransipResourceVpsUpdate
    TestAccTransipResourceVpsUpdate: testing.go:654: Step 1 error: Check failed: Check 1/2 error: transip_vps.test: Attribute 'is_customer_locked' expected "false", got "true"
    TestAccTransipResourceVpsUpdate: testing.go:715: Error destroying resource! WARNING: Dangling resources
        may exist. The full state and error is shown below.

        Error: errors during apply: failed to cancel VPS "aequitasterraformtest-vps16": VPS 'aequitasterraformtest-vps16' is customer locked, no modification is allowed

        State: transip_vps.test:
          ID = aequitasterraformtest-vps16
          provider = provider.transip
          availability_zone = ams0
          cpus = 1
          description = test-1600676840-updated
          disk_size = 52428800
          install_text = 
          ip_address = 37.97.129.162
          ipv4_addresses.# = 1
          ipv4_addresses.0 = 37.97.129.162
          ipv6_addresses.# = 1
          ipv6_addresses.0 = 2a01:7c8:aabc:5ff::1
          is_blocked = false
          is_customer_locked = true
          mac_address = 52:54:00:1b:2c:2e
          memory_size = 1048576
          name = aequitasterraformtest-vps16
          operating_system = ubuntu-20.04
          product_name = vps-bladevps-x1
          status = running
          tags.# = 0
--- FAIL: TestAccTransipResourceVpsUpdate (81.69s)
FAIL
exit status 1
FAIL    github.com/aequitas/terraform-provider-transip  81.713s