cisco-open / terraform-provider-meraki

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

MERAKI_DEBUG environment variable doesn't work #131

Closed zbuchheit closed 1 month ago

zbuchheit commented 1 month ago

Prerequisites

Describe the bug When attempting to use MERAKI_DEBUG=true environment variable with the provider, it doesn't appear to work. Setting it explicitly on the provider works.

Expected behavior Allow use of environment variable MERAKI_DEBUG to get additional debug logs and api calls.

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

Environment (please complete the following information):

Additional context Add any other context about the problem here.

finkjordanj commented 1 month ago

Which OS are you running? I just tested with Ubuntu 22.04 running this with the export MERAKI_DEBUG="true" environment variable set and then turning on the terraform logging to debug i am able to get the debug output correctly without having to include it in the provider block within my code.

If you aren't seeing any log output you may need to change the TF_log level to debug which can be done on ubuntu with export TF_LOG="DEBUG"

zbuchheit commented 1 month ago

hi, thanks for the speedy response.

I am on macOS 14.2.1 I have tried zsh and bash and neither seem to work for me.

This is my minimal setup

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

data "meraki_devices" "example" {
  organization_id = redacted
}

running TF_LOG=debug MERAKI_DEBUG="true" terraform plan and running the export permutations doesn't seem to work either.

obrigg commented 1 month ago

Hi Zach, Can you kindly add meraki_debug = "true" in the TF file?

terraform {
  required_providers {
    meraki = {
      version = "0.2.9-alpha"
      source = "cisco-open/meraki"
    }
  }
}
provider "meraki" {
  meraki_debug = "true"
}
zbuchheit commented 1 month ago

yeah, when I do that it is able to debug as desired. It just doesn't appear to work with the environment variable.

obrigg commented 1 month ago

I see. We can look at making it clearer that this is a configuration in the TF file and not an environment variable (as opposed to TF_LOG=DEBUG, required by Terraform).

zbuchheit commented 1 month ago

The docs detail it should work https://registry.terraform.io/providers/cisco-open/meraki/latest/docs

and looking in the code at a quick glance it looks like it should work but I am unsure why it isn't working for me https://github.com/cisco-open/terraform-provider-meraki/blob/f64fb0a70e9026ee7629cfbebb5eed24adec8551/internal/provider/provider.go#L138

There are instances where it would be more convenient to just use the env variable as opposed to explicitly in the code itself.

fmunozmiranda commented 1 month ago

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

zbuchheit commented 1 month ago

it looks to be working now with the latest version. Thanks!