1

We are using Terraform to make scaling our New Relic dashboards easier and more uniform. This is because we will need to recreate all of our existing dashboards (currently a few dozen) each time we spin up a new client and/or a new product region. As a result, I wish to avoid writing code for each existing dashboard and was hoping to find a way to import an existing NR1 dashboard into Terraform.

At the very bottom of the Example Usage: Create a New Relic One Dashboard, almost as a footnote, the documentation mentions New Relic dashboards can be imported using their GUID. Well, this was only slightly useful as NR1 dashboards do not appear to have GUIDs, at least not the way the OG dashboards did. I was able to import an Insights dashboard before they went away, but could not figure out how to get at the code, which was of course the whole point.

Is it possible to export the HCL to say, VS Code, after import or will we have to recode and test each of our existing dashboards? Thank you for your time.

1 Answers1

0

Currently terraform has no builtin way to generate code from existing infrastructure. There are indeed third party projects like terraformer but unfortunately New Relic is not supported by them.

What you can do is:

  1. Create a dummy resource (e. g. pasting from the terraform registry sample)
  2. Importing the dashboard by the guid
  3. Run terraform plan and check what terraform would destroy/change, you can then rewrite that easily till you have no changes for your dashboards.

This is a bit hacky but i used this in the past for cloud infrastructure and it worked out pretty good.

Timo Reymann
  • 755
  • 5
  • 16
  • 1
    Definitely sounds clunky, but it would be better than writing it all by hand. I'll give it a shot and see if it works for us. – Steeltown Riot May 19 '21 at 19:31
  • It might take me a bit to test this. Since I imported the dashboard once before, it is apparently stuck in the current state and won't let me do it again. I'm struggling to get it reset. Can't seem to refresh it and destroy didn't work either. – Steeltown Riot May 20 '21 at 13:58
  • You can also remove the dashboard from state with terraform state rm dashboard-resource-adress. This should do the trick :) – Timo Reymann May 24 '21 at 10:11