-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
urlparse function to get url parts #23893
Comments
Thanks for sharing this, @matti! Another option with Terraform as it exists today is to use the regular expression given in RFC 3986 Appendix A:
Or, a variant of it using named capture groups for easier consumption of the result:
This particular regex pattern doesn't try to decompose the "authority" portion because it's a generic URL match rather than a scheme-specific match. Perhaps that part could be parsed in a subsequent call where needed, as a way to get this done in current Terraform releases. |
the regexp you provided does not provide the same parts what my module does - I tried to write regexp like that but it is super hard. |
I posted on this subject elsewhere and was re-directed by Martin (thank you Martin): For the hostname only I did the following using the go url.Parse and net.SplitHostPart functions: +var URLToHostNameFunc = function.New(&function.Spec{
+}) I don't think it would be much of a stretch to cover most of the other cases. Kind regards, Lawrence |
Sorry for the broken code insert. |
How disappointing this simple feature is not getting enough attention.
The above is more or less what we keep in out However, for appmesh, we also need to specify the backends to tell envoy to look up their definitions. This is where we need to strip stuff and just leave the domain name. And there's no way to do this in terraform, so we have to split our variables into separate protocols, auth, domain, path etc. It's doable, but could be much easier if there was an |
I'd love this, too. I need to set a DNS record based on an output that can only be a full URL. Without the ability to natively extract the Authority from that full URL, I can't automate my deployment properly. |
I'll have a crack at it @nibblesnbits |
@nibblesnbits @mkielar @apparentlymart Would you mind reviewing this draft PR? If everyone's happy, I'll finish off the docs and convert it to a PR. Thanks 🏖️ |
Any updates here? |
While I cannot speak to whether this might land as a built-in function in the Terraform configuration language, you might find #27696 an interesting issue to track. |
@bflad already tracking it :) |
same here :) |
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! |
a workaround:
https://registry.terraform.io/modules/matti/urlparse/external/0.2.0
The text was updated successfully, but these errors were encountered: