clincha-org / terraform-provider-proxmox

Terraform provider for Proxmox virtual environment
Mozilla Public License 2.0
0 stars 0 forks source link

Networks #2

Closed clincha closed 2 months ago

clincha commented 4 months ago

I want to create, update and delete a network on a Proxmox Virtual Environment node so that I can manage the node's networks in Terraform.

clincha commented 4 months ago

I've updated the code in the API so that there is a Network struct and a NetworkRequest struct. This is because the request that I send to the API is different to the JSON object that is returned.

This makes sense for the API but I'm not sure how I can map that logic into Terraform. I want to have a resource that I can update with specific fields but then a data object that has other fields. I think that I need to go with a NetworkRequest as the resource and then maybe implement a data type in Terraform that reads the network. I'm not really sure at the moment but I'm going to think on it.

clincha commented 4 months ago

I think the issue is resolved by using the schema correctly in Terraform. Some values can be marked as "Computed" and then they can't be set in the Terraform code but are returned when Terraform runs. I'm going to try and create the schema and see if I can work it out

clincha commented 4 months ago

That seemed to work! Networks complete!

clincha commented 4 months ago

Nope... I still haven't completed the update and destroy

clincha commented 3 months ago

I had an issue where I tried to test the creation of a new network. Terraform kept passing in zero values to the API which cased validation errors. I needed it to pass in nil instead. I found this article: https://discuss.hashicorp.com/t/null-value-vs-unknown-value-in-framework-types/52384/2

The article helped me see that I needed to set computed as false for the nil value to be passed through.

"vlan_id": schema.Int64Attribute{
  Optional: true,
  Computed: false,
},
clincha commented 2 months ago

Too large. See #6