Terraform Interpolation inside the Dashboard ConfigJson Field.
MasterExecuson opened this issue · 1 comments
What I'm trying to do:
Create a dashboard, originaly created through UI and exported as JSON, using Crossplane Grafana Provider.
The dashboard has 3K lines, multiple variables, including Datasource Variables.
What I'm facing:
The Datasoruce variable created in the UI uses the notation ${env}
, which is clashing with Terraform Interpolation variables, generating a very unhelpfull error message:
Invalid reference: A reference to a resource type must be followed by at least one attribute access, specifying the resource name
What I expect to happen:
I expect that any dashboard exported through the UI can be crerated using the Crossplane Provider without modifications. In this case, I expect the provider to bypass the Terraform interpolation by default.
I would propose to make a regex replace function that replaces the ${
with $${
. As this change would impact any user that had fixed this issue manually, I also would propose to consider not replacing if there is a $
before ${
. The final Regex would look something like this: (?<!\$)\${
or (?P<char>[^$])${
...
Interim Containment Action
Terraform accepts $${env}
as a way to bypass it's interpolation. Meanwhile I had to replace all ${env}
with the double $.
I also posted the Interim solution on Stackoverflow.