src-d / terraform-provider-online

Terraform provider for Online.net
Mozilla Public License 2.0
19 stars 13 forks source link

Separate logic from server and rpn resources #24

Closed rporres closed 6 years ago

rporres commented 6 years ago

I've spent some trying to fix the bugs that the original implementation had (related to rpn not being cached properly and the retrieval of VLAN from an RPN, that cannot be done by querying Online.net). After a few tries I've come to the conclusion that the coupling between of server and rpn had a few issues:

So instead of fixing the bugs, I've modified the online_server resource to not have any kind of rpn logic and added the server_ids property to the original rpn resource (now named online_rpnv2 to make clearer what it represents)

resource "online_rpnv2" "rafa_test" {
  name = "rafa-test"
  vlan = 2344
  server_ids = [
    "${online-net_server.server1.server_id}",
  ]
}

resource "online_server" "server1" {
  server_id = "139329"
  hostname =  "server1"
}

Since no empty rpn can be created, I've preferred to create a online_rpnv2 resource instead of online_rpnv2_association. It also had two benefits:

Fixes #6, #7 and #8

rporres commented 6 years ago

@meyskens This should be ready. I will squash commits on merge

rporres commented 6 years ago

addressed your comments, @meyskens