Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform Interpolation inside the Dashboard ConfigJson Field. #59

Closed
MasterExecuson opened this issue Jan 15, 2024 · 1 comment · Fixed by #86
Closed

Terraform Interpolation inside the Dashboard ConfigJson Field. #59

MasterExecuson opened this issue Jan 15, 2024 · 1 comment · Fixed by #86

Comments

@MasterExecuson
Copy link

MasterExecuson commented Jan 15, 2024

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 $.

@MasterExecuson
Copy link
Author

I also posted the Interim solution on Stackoverflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant