mschuchard / terraform-provider-stdlib

A collection of additional functions for Terraform
MIT License
1 stars 0 forks source link

Optionally implement terraform-provider-stdlib as a provider-defined function for Terraform 1.8+ #1

Open crw opened 7 months ago

crw commented 7 months ago

Thank you for supporting the Terraform community with this data provider! If you were using the data provider construct to work around the lack of support in Terraform for external functions, please consider the following new feature of Terraform.

Terraform version 1.8 launches with support of provider-defined functions. It is now possible to implement this functionality as a function, rather than wrap the functionality in a data provider. Provider-based functions have the advantage of a simpler in-line syntax that does not require the data block (or any other resource blocks) to use.

The caveat is that, as provider-defined functions are new to Terraform 1.8, you would need to continue to maintain the current data provider functionality if you wished to continue to support earlier versions of Terraform.

Please see the provider-defined functions documentation to learn how to implement functions in your providers. If you have any questions, please visit the Terraform topic in our official forum.

We greatly appreciate your support of the Terraform community with your contributions. If you do not wish to implement this functionality as a function, please feel free to close this issue. This issue is simply to raise awareness of the new capability. Thanks again!

mschuchard commented 7 months ago

Thanks for the notification. I had been asking core team for this feature for years, but I guess I should have been asking the plugin team instead.

I will certainly adopt this eventually once the feature matures, and I can be more confident of the unit/acceptance testing and documentation generation support for this new feature; otherwise I will probably be opening issues and the TF/Packer/Vault plugin teams are all probably tired of seeing me do that.

I also notice that although the interface is nicer this new feature does not support generics (perhaps due to continued reliance on tftype), and that is the biggest obstacle for robust functions in provider data. I am disappointed that this obstacle appears to persist.

crw commented 7 months ago

Thanks for that feedback, I'll pass it along to the development and product team!

mschuchard commented 6 months ago

@crw Do you mind pointing me to an enumeration of the advantages this implementation currently enables versus data sources? My understanding based on documentation is that the primary differences are:

Thank you.

I also checked for the PRs where these features were implemented, and I see now how this was enabled with RPC updates, and that is probably the reason for the typing requirements existing as they are.

crw commented 6 months ago

Hi @mschuchard, I believe your three bullets are correct. Functions are not resources, and thus can be executed during the terraform validate stage whereas data sources are resources, and thus are not resolvable until the plan stage.