newrelic-cli
newrelic-cli copied to clipboard
While converting JSON to TF resource account_id gets ignored in widget query
Description
I am trying to convert some of my dashboards created manually to Terraform. For which I am using the steps provided in https://registry.terraform.io/providers/newrelic/newrelic/latest/docs/resources/one_dashboard#use-the-new-relic-cli-to-convert-an-existing-dashboard
There was no mention here on how to export the terraform into a file but I figured that out by adding -o file.tf
to the command & it did the work.
Go Version
I dont use Go.
Current behavior
When I tried to use the newrelic cli to convert my dashboard.json to a Terraform resource, the account_id gets ignored & not present in the widgets. It comes like this.
nrql_query {
query = <<EOT
query
EOT
}
Expected behavior
The block nrql_query
should also have the account_id associated with that query.
Like this
nrql_query {
account_id = ***
query = <<EOT
query
EOT
}
Steps To Reproduce
Steps to reproduce the behavior:
- Export any dashboard & save as Json file, lets say file is dashboard.json. And make sure you are in a multi account Newrelic organization account where your query needs to be ran on a specific account.
- Make sure to install newrelic cli :)
- Then run
cat dashboard.json | newrelic utils terraform dashboard --label my_dashboard_resource -o dashboard.tf
- Check in the newly created dashboard.tf file & you will see no account_id attribute is present inside
nrql_query
block.
References or Related Issues
https://registry.terraform.io/providers/newrelic/newrelic/latest/docs/resources/one_dashboard#use-the-new-relic-cli-to-convert-an-existing-dashboard
To add more, this is what I have in my JSON inside the nrqlQueries
block
"nrqlQueries": [ { "accountIds": [ ** ], "query": "**" } ]