clincha-org / terraform-provider-proxmox

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

proxmox_network_bridge #6

Closed clincha closed 4 months ago

clincha commented 4 months ago

I have started creating a Terraform resource to manage a "network". This was too big of a start for me. I need to break the problem down into even smaller components. I think that will structure the code better.

I went back to the UI and I tried to create a network manually. I noticed that the UI also has different items for different types of network.

image

I think taking one item from the drop down and working on that until it works well is a better idea. I've decided to start at the top and create a bridge network. I think it's also the most simple.

Screenshot from 2024-07-27 14-14-48

clincha commented 4 months ago

Going to ignore IPv6 for now

clincha commented 4 months ago
Error: Provider produced inconsistent result after apply

When applying changes to proxmox_network_bridge.vmbr88, provider
"provider[\"registry.terraform.io/hashicorp/proxmox\"]" produced an
unexpected new value: .mtu: was null, but now cty.NumberIntVal(1500).

This is a bug in the provider, which should be reported in the provider's own
issue tracker.
clincha commented 4 months ago

I tried to make the MTU default to 1500 in the Terraform code but then it needs to be Computed

    Error: Failed to load plugin schemas

    Error while loading schemas for plugin components: Failed to obtain provider
    schema: Could not load the schema for provider
    registry.terraform.io/hashicorp/proxmox: failed to retrieve schema from
    provider "registry.terraform.io/hashicorp/proxmox": Schema Using Attribute
    Default For Non-Computed Attribute: Attribute "mtu" must be computed when
    using default. This is an issue with the provider and should be reported to
    the provider developers...
clincha commented 4 months ago

https://developer.hashicorp.com/terraform/plugin/framework/handling-data/attributes/bool#configurability

clincha commented 4 months ago

I managed to finally figure out the inconsistent state issues. In the schema I have set values that are not required to have Computed and Optional set to true.

"gateway": schema.StringAttribute{
    Optional: true,
    Computed: true,
},

Then, when I'm running a Create command in Terraform, any values that are "Unknown" get set to nil.

if plan.Gateway.IsUnknown() {
    networkRequest.Gateway = nil
}