newrelic / newrelic-cli

The New Relic Command Line Interface
https://developer.newrelic.com/explore-docs/newrelic-cli
Apache License 2.0
127 stars 72 forks source link

[Feature] Terraform: generate raw dashboard resource #1198

Open danielcorreia96 opened 2 years ago

danielcorreia96 commented 2 years ago

Feature Description

Currently, the newrelic utils terraform dashboard command allows users to export NewRelic dashboards to the Terraform resource, newrelic_one_dashboard (https://registry.terraform.io/providers/newrelic/newrelic/latest/docs/resources/one_dashboard)

However, this command doesn't work for dashboards that use more complex features such as:

The reason this doesn't work is because the unmarshalling schema for the dashboard's "raw configuration" data is either

  1. Missing fields (e.g. no thresholds field)
  2. Or the fields types are incorrect (e.g. dataFormatters is not a list of strings)

(for reference: https://github.com/newrelic/newrelic-cli/blob/e655dbc376b76950773280d8150a32b4805b9cc6/internal/utils/terraform/dashboard.go#L30-L38)

Since covering all of these complex features scenarios both in the newrelic-cli project and the NewRelic Terraform provider is a lot of work, it would be nice if instead there was an alternative command (or flag) that allowed users to export dashboards to the raw dashboard resource in Terraform - newrelic_one_dashboard_raw.

Describe Alternatives

Other than implementing our own Terraform resource generator (similar to the one provided by newrelic-cli), there's no alternative.

Note that, for now, we've managed to workaround this internally by patching the utils terraform dashobard command to support a --raw flag but the current implementation isn't very polished 😅

Additional context

Add any other context here.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs.

stale[bot] commented 2 years ago

This issue has been automatically closed due to a lack of activity for an extended period of time.

kidk commented 2 years ago

Thanks for suggestion @danielcorreia96 Let me discuss with the team to see how hard this would be to implement.