Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meraki_networks_switch_stacks_routing_interfaces - additional fields in the request #118

Open
mcparaf opened this issue Jul 24, 2024 · 5 comments

Comments

@mcparaf
Copy link

mcparaf commented Jul 24, 2024

Prerequisites

  • [ v ] Have you tested the operation in the API directly?
  • [ v ] Do you have the latest Terraform provider version?
  • [ x ] Review the compatibility matrix before opening an issue.

Describe the bug
After creating a switch stack routing interfaces, when I try to edit it the provider includes in the request data that is 1. unnecessary 2. downloaded directly from the Meraki API somehow (as opposed to be provided by me in the terraform project).

2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: PUT  /api/v1/networks/L_709316941310853998/switch/stacks/709316941310853309/routing/interfaces/709316941310853398  HTTP/1.1
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: HOST   : api.meraki.com
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: HEADERS:
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: 	Accept: application/json
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: 	Authorization: Bearer ****b91c9
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: 	Content-Type: application/json
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: 	User-Agent: go-meraki/1.44.1 MerakiTerraform/1.47.0 Cisco
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: BODY   :
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: {
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha:    "interfaceIp": "10.11.100.2",
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha:    "ipv6": {
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha:       "address": "1:2:3:4::1",
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha:       "assignmentMode": "static",
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha:       "gateway": "1:2:3:4::100",
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha:       "prefix": "1:2:3:4::/64"
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha:    },
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha:    "multicastRouting": "disabled",
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha:    "name": "test2",
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha:    "ospfSettings": {
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha:       "area": "ospfDisabled"
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha:    },
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha:    "subnet": "10.11.100.0/24",
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha:    "vlanId": 101
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: }
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: ------------------------------------------------------------------------------
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: ~~~ RESPONSE ~~~
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: STATUS       : 400 Bad Request
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: PROTO        : HTTP/2.0
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: RECEIVED AT  : 2024-07-24T15:17:21.803517+02:00
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: TIME DURATION: 176.528625ms
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: HEADERS      :
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: 	Cache-Control: no-cache, no-store, max-age=0, must-revalidate
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: 	Content-Type: application/json; charset=utf-8
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: 	Date: Wed, 24 Jul 2024 13:17:22 GMT
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: 	Expires: Fri, 01 Jan 1990 00:00:00 GMT
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: 	Pragma: no-cache
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: 	Strict-Transport-Security: max-age=31536000; includeSubDomains
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: 	X-Content-Type-Options: nosniff
2024-07-24T15:17:21.805+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: 	X-Frame-Options: sameorigin
2024-07-24T15:17:21.806+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: 	X-Request-Id: 763fce0d3afc3cfc48d911d85c3aeb46
2024-07-24T15:17:21.806+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: 	X-Robots-Tag: none
2024-07-24T15:17:21.806+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: 	X-Runtime: 0.064556
2024-07-24T15:17:21.806+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: 	X-Xss-Protection: 1; mode=block
2024-07-24T15:17:21.806+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: BODY         :
2024-07-24T15:17:21.806+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: {
2024-07-24T15:17:21.806+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha:    "errors": [
2024-07-24T15:17:21.806+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha:       "IPv6 'gateway' to be set once and is already configured with a different l3 interface."
2024-07-24T15:17:21.806+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha:    ]
2024-07-24T15:17:21.806+0200 [DEBUG] provider.terraform-provider-meraki_v0.2.9-alpha: }

The whole struct ipv6 was not present in the terraform module at all. Furthermore, I changed the problematic gateway field in the Meraki dashboard itself and then I have seen the updated data in my request.

resource "meraki_networks_switch_stacks_routing_interfaces" "net_switch_stacks_routing_interfaces" {
  for_each        = { for i, v in local.networks_switch_stacks_routing_interfaces : i => v }
  switch_stack_id = each.value.switch_stack_id
  network_id      = each.value.network_id
  default_gateway = try(each.value.data.default_gateway, null)
  # interface_id      = try(each.value.data.interface_id, null)
  interface_ip      = try(each.value.data.interface_ip, null)
  # ipv6              = try(each.value.data.ipv6, null)
  multicast_routing = try(each.value.data.multicast_routing, null)
  name              = try(each.value.data.name, null)
  ospf_settings     = try(each.value.data.ospf_settings, null)
  # ospf_v3           = try(each.value.data.ospf_v3, null)
  subnet  = try(each.value.data.subnet, null)
  vlan_id = try(each.value.data.vlan_id, null)
}

Expected behavior
The routing interface object reflects directly the data that I have provided to it without any additions, removals or modifications.

Environment (please complete the following information):

  • Meraki Dashboard version: n260.meraki.com
  • Terraform version: 1.9.1
  • Meraki provider version: 0.2.9-alpha
  • OS Version: macOS Sonoma 14.5
fmunozmiranda added a commit that referenced this issue Aug 5, 2024
* Issue #117 Fixed.
* Issue #118 Fixed.
* Issue #120 Fixed.
* Issue #121 Fixed.
* Issue #122 Fixed.
* Issue #123 Fixed.
* Issue #124 Fixed.
* Issue #125 Fixed.
* Issue #126 Fixed.
* Issue #127 Fixed.
* Issue #128 Fixed.
* Issue #129 Fixed.
* Issue #130 Fixed.
* Issue #131 Fixed.
@fmunozmiranda fmunozmiranda mentioned this issue Aug 5, 2024
13 tasks
@fmunozmiranda
Copy link
Collaborator

@mcparaf please try it with new version and update us.

@mcparaf
Copy link
Author

mcparaf commented Aug 7, 2024

Unfortunately, a similar error still happens, even after updating to 2.10-alpha:

2024-08-07T14:34:13.363+0200 [DEBUG] module.meraki.meraki_networks_switch_stacks_routing_interfaces.net_switch_stacks_routing_interfaces["EMEA/Dev/Dev/stacks/DEV_ACCESS/interfaces/test2"]: applying the planned Update change
2024-08-07T14:34:14.024+0200 [DEBUG] provider.terraform-provider-meraki: 2024/08/07 14:34:14
2024-08-07T14:34:14.025+0200 [DEBUG] provider.terraform-provider-meraki: ==============================================================================
2024-08-07T14:34:14.025+0200 [DEBUG] provider.terraform-provider-meraki: ~~~ REQUEST ~~~
2024-08-07T14:34:14.025+0200 [DEBUG] provider.terraform-provider-meraki: PUT  /api/v1/networks/L_709316941310853998/switch/stacks/709316941310853309/routing/interfaces/709316941310853404  HTTP/1.1
2024-08-07T14:34:14.025+0200 [DEBUG] provider.terraform-provider-meraki: HOST   : api.meraki.com
2024-08-07T14:34:14.025+0200 [DEBUG] provider.terraform-provider-meraki: HEADERS:
2024-08-07T14:34:14.025+0200 [DEBUG] provider.terraform-provider-meraki: 	Accept: application/json
2024-08-07T14:34:14.025+0200 [DEBUG] provider.terraform-provider-meraki: 	Authorization: Bearer ****b91c9
2024-08-07T14:34:14.025+0200 [DEBUG] provider.terraform-provider-meraki: 	Content-Type: application/json
2024-08-07T14:34:14.026+0200 [DEBUG] provider.terraform-provider-meraki: 	User-Agent: go-meraki/1.44.1 MerakiTerraform/1.47.0 Cisco
2024-08-07T14:34:14.026+0200 [DEBUG] provider.terraform-provider-meraki: BODY   :
2024-08-07T14:34:14.026+0200 [DEBUG] provider.terraform-provider-meraki: {
2024-08-07T14:34:14.027+0200 [DEBUG] provider.terraform-provider-meraki:    "interfaceIp": "10.11.100.2",
2024-08-07T14:34:14.027+0200 [DEBUG] provider.terraform-provider-meraki:    "ipv6": {},
2024-08-07T14:34:14.027+0200 [DEBUG] provider.terraform-provider-meraki:    "multicastRouting": "disabled",
2024-08-07T14:34:14.027+0200 [DEBUG] provider.terraform-provider-meraki:    "name": "test2",
2024-08-07T14:34:14.027+0200 [DEBUG] provider.terraform-provider-meraki:    "ospfSettings": {
2024-08-07T14:34:14.027+0200 [DEBUG] provider.terraform-provider-meraki:       "area": "ospfDisabled"
2024-08-07T14:34:14.027+0200 [DEBUG] provider.terraform-provider-meraki:    },
2024-08-07T14:34:14.027+0200 [DEBUG] provider.terraform-provider-meraki:    "subnet": "10.11.100.0/24",
2024-08-07T14:34:14.027+0200 [DEBUG] provider.terraform-provider-meraki:    "vlanId": 101
2024-08-07T14:34:14.027+0200 [DEBUG] provider.terraform-provider-meraki: }
2024-08-07T14:34:14.027+0200 [DEBUG] provider.terraform-provider-meraki
2024-08-07T14:34:14.027+0200 [DEBUG] provider.terraform-provider-meraki: ------------------------------------------------------------------------------
2024-08-07T14:34:14.027+0200 [DEBUG] provider.terraform-provider-meraki: ~~~ RESPONSE ~~~
2024-08-07T14:34:14.027+0200 [DEBUG] provider.terraform-provider-meraki: STATUS       : 400 Bad Request
2024-08-07T14:34:14.027+0200 [DEBUG] provider.terraform-provider-meraki: PROTO        : HTTP/2.0
2024-08-07T14:34:14.027+0200 [DEBUG] provider.terraform-provider-meraki: RECEIVED AT  : 2024-08-07T14:34:14.024294+02:00
2024-08-07T14:34:14.027+0200 [DEBUG] provider.terraform-provider-meraki: TIME DURATION: 179.531208ms
2024-08-07T14:34:14.027+0200 [DEBUG] provider.terraform-provider-meraki: HEADERS      :
2024-08-07T14:34:14.028+0200 [DEBUG] provider.terraform-provider-meraki: 	Cache-Control: no-cache, no-store, max-age=0, must-revalidate
2024-08-07T14:34:14.028+0200 [DEBUG] provider.terraform-provider-meraki: 	Content-Type: application/json; charset=utf-8
2024-08-07T14:34:14.028+0200 [DEBUG] provider.terraform-provider-meraki: 	Date: Wed, 07 Aug 2024 12:34:14 GMT
2024-08-07T14:34:14.028+0200 [DEBUG] provider.terraform-provider-meraki: 	Expires: Fri, 01 Jan 1990 00:00:00 GMT
2024-08-07T14:34:14.028+0200 [DEBUG] provider.terraform-provider-meraki: 	Pragma: no-cache
2024-08-07T14:34:14.028+0200 [DEBUG] provider.terraform-provider-meraki: 	Strict-Transport-Security: max-age=31536000; includeSubDomains
2024-08-07T14:34:14.028+0200 [DEBUG] provider.terraform-provider-meraki: 	X-Content-Type-Options: nosniff
2024-08-07T14:34:14.028+0200 [DEBUG] provider.terraform-provider-meraki: 	X-Frame-Options: sameorigin
2024-08-07T14:34:14.028+0200 [DEBUG] provider.terraform-provider-meraki: 	X-Request-Id: 82bc65648d3423e9886332fa6561ca3f
2024-08-07T14:34:14.028+0200 [DEBUG] provider.terraform-provider-meraki: 	X-Robots-Tag: none
2024-08-07T14:34:14.028+0200 [DEBUG] provider.terraform-provider-meraki: 	X-Runtime: 0.101911
2024-08-07T14:34:14.028+0200 [DEBUG] provider.terraform-provider-meraki: 	X-Xss-Protection: 1; mode=block
2024-08-07T14:34:14.028+0200 [DEBUG] provider.terraform-provider-meraki: BODY         :
2024-08-07T14:34:14.028+0200 [DEBUG] provider.terraform-provider-meraki: {
2024-08-07T14:34:14.028+0200 [DEBUG] provider.terraform-provider-meraki:    "errors": [
2024-08-07T14:34:14.028+0200 [DEBUG] provider.terraform-provider-meraki:       "IPv6 prefix is required"
2024-08-07T14:34:14.028+0200 [DEBUG] provider.terraform-provider-meraki:    ]
2024-08-07T14:34:14.028+0200 [DEBUG] provider.terraform-provider-meraki: }

Please note that this is the update change, not the create change. After running Terraform for the first time this will probably be ok, because the create operation seems to be unaffected. You have to run it a second time to trigger the update.

The problematic field is ipv6: {} in the body. It shouldn't be present in the request. I commented it out in my Terraform module:

resource "meraki_networks_switch_stacks_routing_interfaces" "net_switch_stacks_routing_interfaces" {
  for_each        = { for i, v in local.networks_switch_stacks_routing_interfaces : v.interface_key => v }
  switch_stack_id = each.value.switch_stack_id
  network_id      = each.value.network_id
  default_gateway = try(each.value.data.default_gateway, local.defaults.meraki.networks.switch_stacks_routing_interfaces.default_gateway, null)
  # interface_id = try(each.value.data.interface_id, local.defaults.meraki.networks.switch_stacks_routing_interfaces.interface_id, null)
  interface_ip      = try(each.value.data.interface_ip, local.defaults.meraki.networks.switch_stacks_routing_interfaces.interface_ip, null)
  # ipv6              = try(each.value.data.ipv6, local.defaults.meraki.networks.switch_stacks_routing_interfaces.ipv6, null)
  multicast_routing = try(each.value.data.multicast_routing, local.defaults.meraki.networks.switch_stacks_routing_interfaces.multicast_routing, null)
  name              = try(each.value.data.name, local.defaults.meraki.networks.switch_stacks_routing_interfaces.name, null)
  ospf_settings     = try(each.value.data.ospf_settings, local.defaults.meraki.networks.switch_stacks_routing_interfaces.ospf_settings, null)
  # ospf_v3 = try(each.value.data.ospf_v3, local.defaults.meraki.networks.switch_stacks_routing_interfaces.ospf_v3, null)
  subnet  = try(each.value.data.subnet, local.defaults.meraki.networks.switch_stacks_routing_interfaces.subnet, null)
  vlan_id = try(each.value.data.vlan_id, local.defaults.meraki.networks.switch_stacks_routing_interfaces.vlan_id, null)
}

@fmunozmiranda
Copy link
Collaborator

Please try it with new version and update us.

@mcparaf
Copy link
Author

mcparaf commented Aug 22, 2024

The creates and updates now work fine but it is impossible to delete the ipv6 field from the resource. It is visible even during the terraform planning stage.

Consider the following scenario:

  1. an IPv6 interface is created (this works)
  2. a decision is made to downgrade it to IPv4 only. The IPv6 field is removed from the request in the terraform resource. It is however invisible to terraform plan and is not introduced as a change to the API.

@fmunozmiranda
Copy link
Collaborator

@mcparaf Could you please provide an example of what you are trying?

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

No branches or pull requests

2 participants