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

Interpolation of variables in backend.tf #26

Closed
samar-upadhyay opened this issue Apr 29, 2021 · 6 comments
Closed

Interpolation of variables in backend.tf #26

samar-upadhyay opened this issue Apr 29, 2021 · 6 comments

Comments

@samar-upadhyay
Copy link

I want to be able to use a variable in the key field in backend.tf for azurerm provider. The use case is that I am building a self service app registration component and I want to keep application specific tfstate files separate. I want to append app name in the key. Currently, there isn't a way to do it.

@tiny-dancer
Copy link
Contributor

Thank you @samar-upadhyay. To clarify, by app name are you referring to a runiac provided variable, e.g. runiac_project?

@samar-upadhyay
Copy link
Author

@tiny-dancer - Possibly. We could probably use this variable to build the key in backend.tf if we added the substitution in the interpolation code. Or it could be any fringe variable that can be used to build the key. It just happens to be app name in our case.
In my runiac.yml, I have:

project: application-resource-creation

Application name (app1, app2, etc.) is an input variable based on which the project provisions the necessary resources needed to run the application. I want the state file to be unique per application so I have the ability to destroy the application resources and recreate them. So the key name would be something like this:

key = "${var.app_name}.${var.runiac_step}.terraform.tfstate"

@tiny-dancer
Copy link
Contributor

Ah, okay. That adds a bit of complexity to generally support incoming variables for interpolation, up to this point we've been leveraging a select few variable in a quick win fashion. We won't be adding support for general variable interpolation in the current fashion. We may switch to use template files which would help accomplish this.

Additionally you could leverage entrypoint.sh to do any string interpolation or templating as desired.

@tiny-dancer
Copy link
Contributor

tiny-dancer commented May 4, 2021

#24 may be of interest as well

@samar-upadhyay
Copy link
Author

Ah, okay. That adds a bit of complexity to generally support incoming variables for interpolation, up to this point we've been leveraging a select few variable in a quick win fashion. We won't be adding support for general variable interpolation in the current fashion. We may switch to use template files which would help accomplish this.

Additionally you could leverage entrypoint.sh to do any string interpolation or templating as desired.

OK. That is currently what I'm doing.

@samar-upadhyay
Copy link
Author

#24 may be of interest as well

Interesting. I'll take a look.

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

No branches or pull requests

2 participants