Skip to content

Conversation

@sudomateo
Copy link
Collaborator

Registered the existing oxide_switch_port_settings resource and added public facing documentation and a changelog entry.

@sudomateo sudomateo force-pushed the switch-port-settings branch from 8362811 to 0aa3e92 Compare July 31, 2025 16:22
@sudomateo
Copy link
Collaborator Author

For context we merged #426 without registering the oxide_switch_port_settings resource with Terraform and opened this pull request to re-register the resource. We'll use this draft pull request to:

  • Give the networking team a place to build and test the Terraform provider with the oxide_switch_port_settings resource.
  • Iterate on the design of the networking API and oxide_switch_port_settings resource.

We will merge this pull request once this resource becomes ready for customer usage or if we get the networking APIs to a point where we consider them stable for the near to mid future.

@sudomateo sudomateo force-pushed the switch-port-settings branch from 0aa3e92 to 9b9a6de Compare August 5, 2025 14:24
@sudomateo sudomateo force-pushed the switch-port-settings branch 2 times, most recently from be1fe18 to 8c17845 Compare September 5, 2025 22:07
@rcgoodfellow
Copy link

Ran into an issue with adding an address to an existing settings object

ry@rymb:~/oxtf/ipv6$ terraform apply
╷
│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│  - oxidecomputer/oxide in /Users/ry/src/terraform-provider-oxide
│
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become
│ incompatible with published releases.
╵
oxide_address_lot.v6-infra: Refreshing state... [id=1d6a2b9b-d41a-416c-9998-85a6a4f69102]
oxide_address_lot.infra: Refreshing state... [id=c452983f-ff20-46a4-b8aa-278e854fb258]
oxide_switch_port_settings.uplink3: Refreshing state... [id=42d3104e-c4be-482d-8cb4-78120dab427a]
oxide_switch_port_settings.uplink2: Refreshing state... [id=0b8b6992-b15b-4501-a474-7231d8fdf269]
oxide_switch_port_settings.uplink1: Refreshing state... [id=2aae7d51-0b2d-42a8-b5af-8d10cb5efbcc]
oxide_switch_port_settings.uplink0: Refreshing state... [id=7fccd0a8-a0ce-47af-b5cd-0db720bd8359]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following
symbols:
  ~ update in-place

Terraform will perform the following actions:

  # oxide_switch_port_settings.uplink0 will be updated in-place
  ~ resource "oxide_switch_port_settings" "uplink0" {
      ~ addresses     = [
          - {
              - addresses = [
                  - {
                      - address        = "198.51.101.2/30" -> null
                      - address_lot_id = "c452983f-ff20-46a4-b8aa-278e854fb258" -> null
                    },
                ] -> null
              - link_name = "phy0" -> null
            },
          + {
              + addresses = [
                  + {
                      + address        = "198.51.101.2/30"
                      + address_lot_id = "c452983f-ff20-46a4-b8aa-278e854fb258"
                    },
                  + {
                      + address        = "fd00:101::2/126"
                      + address_lot_id = "1d6a2b9b-d41a-416c-9998-85a6a4f69102"
                    },
                ]
              + link_name = "phy0"
            },
        ]
      ~ id            = "7fccd0a8-a0ce-47af-b5cd-0db720bd8359" -> (known after apply)
        name          = "default-uplink0"
      ~ time_created  = "2025-12-19 18:17:54.232531 +0000 UTC" -> (known after apply)
      ~ time_modified = "2025-12-19 18:17:54.232531 +0000 UTC" -> (known after apply)
        # (4 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

oxide_switch_port_settings.uplink0: Modifying... [id=7fccd0a8-a0ce-47af-b5cd-0db720bd8359]
╷
│ Error: Error updating switch port settings
│
│   with oxide_switch_port_settings.uplink0,
│   on generated.tf line 244, in resource "oxide_switch_port_settings" "uplink0":
│  244: resource "oxide_switch_port_settings" "uplink0" {
│
│ API error: POST http://198.51.100.22/v1/system/networking/switch-port-settings
│ ----------- RESPONSE -----------
│ Status: 400
│ Message: unable to parse JSON body: bgp_peers[0].peers[0]: missing field `communities` at line 1 column 544
│ RequestID: bb8db419-4ac4-4a2f-951f-a95f5e55a2eb
│ ------- RESPONSE HEADERS -------
│ Content-Length: [173]
│ Date: [Fri, 19 Dec 2025 18:43:02 GMT]
│ Content-Type: [application/json]
│ X-Request-Id: [bb8db419-4ac4-4a2f-951f-a95f5e55a2eb]
│
╵

Copy link
Collaborator Author

Can you show me your Terraform configuration? I'll do a local test meanwhile.

Registered the existing `oxide_switch_port_settings` resource and added
public facing documentation and a changelog entry.
@sudomateo sudomateo force-pushed the switch-port-settings branch from 8c17845 to f129c8c Compare December 19, 2025 20:25
Copy link
Collaborator Author

Ah. The current code on the switch-port-settings branch uses a Go SDK that serializes communities as omitempty.

	// Communities is include the provided communities in updates sent to the peer.
	Communities []int `json:"communities,omitempty" yaml:"communities,omitempty"`

My local testing shows the error as well.

oxide_switch_port_settings.example: Creating...
╷
│ Error: Error creating switch port settings
│
│   with oxide_switch_port_settings.example,
│   on main.tf line 12, in resource "oxide_switch_port_settings" "example":
│   12: resource "oxide_switch_port_settings" "example" {
│
│ API error: POST http://127.0.0.1:12220/v1/system/networking/switch-port-settings
│ ----------- RESPONSE -----------
│ Status: 400
│ Message: unable to parse JSON body: bgp_peers[0].peers[0]: missing field `communities` at line 1 column 456
│ RequestID: 9aa01b92-e19a-4bd5-8b27-66d45884ce89
│ ------- RESPONSE HEADERS -------
│ Content-Length: [173]
│ Date: [Fri, 19 Dec 2025 20:21:22 GMT]
│ Content-Type: [application/json]
│ X-Request-Id: [9aa01b92-e19a-4bd5-8b27-66d45884ce89]

The default branch uses a Go SDK that serializes communities without omitempty, making it a required parameter.

	// Communities is include the provided communities in updates sent to the peer.
	Communities []int `json:"communities" yaml:"communities"`

I rebased onto main and now the error is gone.

oxide_switch_port_settings.example: Creating...
oxide_switch_port_settings.example: Creation complete after 0s [id=0e87a2b3-89c9-4e27-88bc-91049744dc1b]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

You can pull the latest branch as well and try again. You should be good to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants