-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
feature: String function for multi replacement with map for values #30260
Comments
Thanks for the enhancement request! I've added it to the list of things to triage. |
@crw If you want I can make a sample PR of what this would change would ideally look like to make things easier. |
Thanks for the offer. I think the description above does a pretty good job of describing what is desired, if a sample PR is desired I'll update this thread (or more likely, a dev will join the discussion to elaborate). |
See also #26838 for background |
@jbardin only issue with other proposal is that applies only to |
so no progress, then? |
No, although thanks for the bump. This function would most likely need to be built as a plugin function provider, as opposed to a function built into Terraform. As such it is waiting for the implementation of plugin function providers. Please see: |
Thank you for your continued interest in this issue. Terraform version 1.8 launches with support of provider-defined functions. It is now possible to implement your own functions! We would love to see this implemented as a provider-defined function. Please see the provider-defined functions documentation to learn how to implement functions in your providers. If you are new to provider development, learn how to create a new provider with the Terraform Plugin Framework. If you have any questions, please visit the Terraform Plugin Development category in our official forum. We hope this feature unblocks future function development and provides more flexibility for the Terraform community. Thank you for your continued support of Terraform! |
Description
Ideally with the deprecation of the template provider, there would a string function equivalent for doing a multi replace in a string with a map given for values
Use-cases
Use cases are for module deveoplers that sometimes needs to edit some user input and then inject that into other user input for complex queries. There are probably other use cases as well, but this is the first that comes to mind.
Attempted Solutions
There are some work arounds that people have done with current functions, but they become very complex very quick. One to note is this example from this stackoverflow question. This seems like overkill for something fairly common.
Proposal
Ideally there would be a function that takes a string then a map and does a replace based on what's in the map for values in {} if found. For the above example there would be something like this:
Please let me know if there are any questions/concerns regarding this. I'm open to any other implementation ideas, just want to make the end user experience easier for this common use case.
The text was updated successfully, but these errors were encountered: