Example Snowflake Account setup using tofu demonstratig usage of SnowForm Modules
This repository configures a Snowflake account (INOVEX_TF_MODULES in organization ERUVBJC) using Terraform/OpenTofu. The configured resources include:
Databases & Schemas:
COMMONdatabase with aCOMMONschema (configured with managed access and non-transient).
Imported Data Shares:
CUSTOMER_LEADS_IMPORTED_DB(from shareERUVBJC.INOVEX_PARTNER.CUSTOMER_LEADS_SHARE)WEB_UI_IMPORTED_DB(from shareERUVBJC.INOVEX_PARTNER.WEB_UI_SHARE) These shares are mapped to local databases and made available to theSYSADMINrole using thesnowform_import_listingmodule.
Roles & Access Control:
- Access roles are dynamically generated for the
COMMONdatabase and schema using thesnowform_access_rolesmodule. - Specific privileges (e.g.,
CREATE NETWORK RULE) are explicitly granted toSECURITYADMINon theCOMMONschema. - The setup utilizes dedicated providers for
SYSADMIN,USERADMIN, andSECURITYADMINroles, authenticating via Key-Pair (JWT).
This repository uses GitHub Actions Artifacts to store the encrypted Terraform state file. By default, GitHub imposes a retention limit of 90 days on workflow artifacts. If no pipeline successfully runs and uploads a new state within 90 days, the Terraform state artifact will expire and be permanently deleted by GitHub.
When this happens, the underlying Terraform state is completely destroyed. OpenTofu/Terraform will view this as an empty state, and any subsequent pipeline runs will attempt to recreate all your Snowflake resources from scratch (which can cause failures or duplicate resources).
To safely recover from an expired state:
- You must completely recreate the state utilizing Terraform/OpenTofu
import {}blocks in your configurations. - The
import {}blocks will map your exact live Snowflake configuration components back into memory. - Pushing these changes will allow the pipeline to execute
tofu apply, which will absorb your existing resources, reconstruct a fresh state file, and upload a brand new artifact—effectively restarting the 90-day timer.
Or if there is nothing important in the test account, just delete all the resources and recreate them with terraform.
Otherwise, to prevent the state from being lost, ensure you run the pipeline to update the state at least once every 90 days.
The following screenshot demonstrates an example of logically grouping the tables from imported shares for a consumer role CONSUMER_ROLE. The screenshot shows the perspective of the CONSUMER_ROLE in the Snowsight Horizon Catalog.
