cisco-open / terraform-provider-meraki

A Terraform Provider for Cisco Meraki
Mozilla Public License 2.0
14 stars 5 forks source link

meraki_networks_firmware_upgrades throws error when `products` set #108

Closed zbuchheit closed 1 month ago

zbuchheit commented 1 month ago

Prerequisites

Describe the bug

When attempting to use meraki_networks_firmware_upgrades with products set I get the following error back from the API

    BODY         :
    {
       "errors": [
          "camera does not exist in selected network",
          "sensor does not exist in selected network"
       ]
    }

Expected behavior

I would expect the resource to create successfully with my desired nextUpgrade value.

Example Code


terraform {
  required_providers {
    meraki = {
      source = "cisco-open/meraki"
      version = "0.2.5-alpha"
    }
  }
}

provider "meraki" {
  meraki_debug = "true"
}

resource "meraki_networks_firmware_upgrades" "firmware_upgrades" {
  network_id = "redacted"
  timezone = "America/Los_Angeles"
  upgrade_window = {
    day_of_week = "thu"
    hour_of_day = "23:00"
  }
  products = {
    wireless = {
      next_upgrade = {
        time = "2024-08-10T23:00:00Z"
        to_version = {
          id = "3183"
        }
      }
    }
  }
}

Environment (please complete the following information):

Additional context Add any other context about the problem here.

fmunozmiranda commented 1 month ago

Do you test it directly in API? It works?

zbuchheit commented 1 month ago

API is fine, it seems because the PUT via the provider is getting sent with camera and sensor as {} despite it not being contained in the code and also it doesn't exist on the network I am working with.

Looking in the logs this is what the PUT request body is

 BODY   :
    {
       "products": {
          "appliance": {
             "nextUpgrade": {
                "toVersion": {}
             },
             "participateInNextBetaRelease": false
          },
          "camera": {},
          "cellularGateway": {
             "nextUpgrade": {
                "toVersion": {}
             },
             "participateInNextBetaRelease": false
          },
          "sensor": {},
          "switch": {
             "nextUpgrade": {
                "toVersion": {}
             },
             "participateInNextBetaRelease": false
          },
          "wireless": {
             "nextUpgrade": {
                "time": "2024-08-10T23:00:00Z",
                "toVersion": {
                   "id": "3183"
                }
             },
             "participateInNextBetaRelease": false
          }
       },
       "timezone": "America/Los_Angeles",
       "upgradeWindow": {
          "dayOfWeek": "thu",
          "hourOfDay": "23:00"
       }
    }
    ------------------------------------------------------------------------------

When I use a GET to query the values there is no camera or sensor so the API call I would want/expect the provider to make would be the same as above just without "sensor": {}, and "camera": {},

fmunozmiranda commented 1 month ago

If we do not receive a response it will be closed in the next 24 hours.