-
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
Add a String contains
or includes
function that can replace the can(regex(..., ...))
pattern
#27198
Comments
Can the pull request from January be reviewed and incorporated in the next release? :) |
Hashicorp, y'all have been sitting on this one for over a year since the last comment; almost 2 years since the PR was submitted. It solves a very common use case. Please expedite its inclusion into the next release. |
would love to see this in the next release.... |
Any plans on including this in an upcoming release? Thanks! |
It is very difficult for us to make forward-looking statements, however the linked PR is on the radar for future inclusion. |
@crw I believe this was resolved with #33069 introducing the |
Thanks @bflad, I appreciate the callout. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Current Terraform Version
Use-cases
The current solution for checking if a string var or local contains a given substring is typically done using
can(regex("substring_to_check", var.my_string))
(and there are a number of other ways to do so as well). IMHO, this is pretty unintuitive as it requires using a couple functions and doesn't "read" well.The end goal of providing a specific function to handle this problem is to provide a cleaner and more concise way to accomplish the same.
Attempted Solutions
As mentioned above, the current solution is typically done with
regex
and pals. There are many ways to accomplish this.Proposal
I'm proposing that Terraform provide a native function to handle this instead of the unintuitive ways it's handled now. This can be seen in many programming languages:
I believe a new function like
contains
(problematic because of the Collectioncontains
function?) orincludes
would solve this problem elegantly. I think this is worth bringing up since this is such common business logic pattern.References
N/A
The text was updated successfully, but these errors were encountered: