cisco-open / terraform-provider-meraki

A Terraform Provider for Cisco Meraki
Mozilla Public License 2.0
15 stars 6 forks source link

`meraki_networks_vlan_profiles` silently fails when attempting to create a resource on the default profile #94

Closed zbuchheit closed 1 month ago

zbuchheit commented 2 months ago

Prerequisites

Describe the bug

When attemping to create a meraki_networks_vlan_profiles resource/edit the default vlan profile resource, it will fail to actually enact a change despite reporting a success on the create.

Expected behavior

I would likely expect a resource already exists error and with an import required. The default profile is created automatically so it is a bit of a one-off resource that I could see an argument made for doing a PUT on the create in the even the resource is the default profile. This also makes it tricky to handle the delete as you likely can't/wouldn't delete this resource and would just revert the changes back to default.

Screenshots

Please provide an screenshot of the successful API call with cuRL, Postman, etc.

Environment (please complete the following information):

Additional context

I assume this is likely from this recent code changes where it changes from UpdateNetworkVLANProfile to CreateNetworkVLANProfile on the create which would explain the behavior we saw before which would allow changes on the default vlan profiles, but other vlan profile resource creations would fail. This is the opposite behavior I am seeing now.

Also worth noting, if you create the resource on the Default profile where it doesn't actually make a change, you can refresh, then trigger an update, to which the resource will actually update as expected.

Code Example


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

provider "meraki" {
  meraki_debug = "true"
}

resource "meraki_networks_vlan_profiles" "vlan_profiles" {
   network_id = "redacted"
   iname = "Default"
   name = "Default Profile"
   vlan_names = [ {
      name = "default",
      vlan_id = "1"
   }, {
    name = "guest",
    vlan_id = "2"
   }]
   vlan_groups = []
}
zbuchheit commented 1 month ago

@fmunozmiranda I see this was mentioned being fixed in the 0.2.6 but I am not seeing a commit where the behavior was changed. Could you confirm this issue was addressed in the 0.2.6 release?

fmunozmiranda commented 1 month ago

Could you help us sharing the provider DEBUG?

zbuchheit commented 1 month ago

sure I will provide additional context.

The logs show the following when doing an apply with the above code

2024-07-16T14:55:04.269-0700 [DEBUG] meraki_networks_vlan_profiles.vlan_profiles: applying the planned Create change
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha: 2024/07/16 14:55:04 
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha: ==============================================================================
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha: ~~~ REQUEST ~~~
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha: GET  /api/v1/networks/redacted/vlanProfiles/Default  HTTP/1.1
...
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha: BODY   :
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha: ***** NO CONTENT *****
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha: ------------------------------------------------------------------------------
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha: ~~~ RESPONSE ~~~
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha: STATUS       : 200 OK
...
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha: BODY         :
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha: {
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha:    "name": "Default Profile",
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha:    "iname": "Default",
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha:    "vlanNames": [
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha:       {
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha:          "name": "default",
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha:          "vlanId": "1"
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha:       }
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha:    ],
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha:    "vlanGroups": [],
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha:    "isDefault": true
2024-07-16T14:55:04.437-0700 [DEBUG] provider.terraform-provider-meraki_v0.2.7-alpha: }

It then saves the vlan_profile into the state.

fmunozmiranda commented 1 month ago

@zbuchheit please try it again with new version.

zbuchheit commented 1 month ago

this appears to be fixed. Thanks