Replies: 2 comments 6 replies
-
@jmkacz hello! I hope you are doing well. In regards to your questions, I would highly discourage method 1. Although this is still supported for legacy reasons, it is not considered current best practice. Method 2 is only an option if there is a default provider (no alias). This works if you make multiple modules, each using only one implicit provider. You could still have "foo_bar_schema" module as described above, but internally it would be composed of three modules, each using a different implicit provider. This is convenient because you do not need to add any additional blocks to resources within these modules, but it does require you to split up your Terraform code, which make not make sense with your current architecture. snowflake_schema module
Method 3 is also a valid option, but it would require you to explicitly select the provider for each resource, which is a bit more code. This is what is done in the Terraforming Snowflake tutorial, but personally I do not like it as much. Note that you could mix method 2 and method 3, just pick a provider to be the default. Finally, I would not thinking of it as "pass them to the module on every invocation" as much as "pass reference to each module for use during apply" since the plugin still only gets initialized once, not multiple times. |
Beta Was this translation helpful? Give feedback.
-
@sfc-gh-swinkler Hello! I think account admin is also necessary like when creating a storage integration. |
Beta Was this translation helpful? Give feedback.
-
Cross-posting from https://community.snowflake.com/s/question/0D5VI000005xtFR0AY/what-are-best-practices-for-making-snowflake-terraform-modules as the communities might not overlap significantly.
Background, we went through the Snowflake Quickstart, Terraforming Snowflake (https://quickstarts.snowflake.com/guide/terraforming_snowflake/index.html#0).
We want to make a helper module for creating schemas, as there's a pile of common configurations we want create for every new schema (roles, privileges, etc). We have separate providers for each of SECURITYADMIN, SYSADMIN, and USERADMIN, as we are following Snowflake best practices and not creating everything under ACCOUNTADMIN.
A couple of questions,
Example for the third option:
The right-hand side of these providers passed in will not change and will be the same for all of these invocations.
This came from a discussion on this documentation, https://developer.hashicorp.com/terraform/language/modules/develop/providers#providers-within-modules
There is nuanced difference though. In the Hashicorp documentation, they are switching between providers, say for different aws regions; whereas we're not switching providers.
So, net, what is the recommended way to build a helper module for the snowflake terraform plugin?
Beta Was this translation helpful? Give feedback.
All reactions