hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.4k stars 9.5k forks source link

Feature Request: splitwords interpolation function #18008

Open joshringer opened 6 years ago

joshringer commented 6 years ago

There is already some functionality in place to identify words in strings, namely the title(string) function. I think it would be useful to provide this as a separate interpolation function splitwords(string), which splits a string into a list of word strings.

This would provide a flexible way of converting strings in cases where one requires a particular format for a value. E.g.

Currently, the best—somewhat dirty—way of achieving this that I can think of is a long list of split+joins:

"${join("_", split(" ", join(" ", split("_", join(" ", split("-", var.name))))))}"
crw commented 6 months ago

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!