Project curator: Amir Jaber ( github, linkedin, email: amir@rittmananalytics.com )
Inspired by the Medium article Terraforming Snowflake (the Easy Way)
This package is a WORK IN PROGRESS. It aims to automate migration of Snowflake instances to Terraform by performing the following tasks:
- extract all objects in Snowflake which map to a Terraform
resource
. - create terraform files with resources made to map to each live object.
Snowglober automates the creation of the terraform.tfvars
file, which is used by Terraform for variable definitions. It generates this file using your existing environment variables. If a variable already exists in terraform.tfvars
, Snowglober will not overwrite it.
-
Ensure your environment variables match (case-insensitively) with the variables listed in the project's Environment Variables section.
-
Run Snowglober. It creates the
terraform.tfvars
file based on your environment variables. -
Run your usual Terraform commands. The
terraform.tfvars
file is automatically included in these commands, for example, when you runterraform apply
.
snowglober's .tf
file generation workflow
- set up
provider
andvariable
files; variables contain creds and are populated from.env
vars - query snowflake for all objects of each resource type
- generate
.tf
files with resources - at this stage only required properties are defined - run
terraform init
- run
terraform import
for each resource - extract remaining (and optional) properties from the generated
.tfstate
file - update the resources in the
.tf
files with the remaining properties
This package is open source in nature, under the MIT license. Anyone who wants to contribute is free to do so, just reach out!
pip install -e /path/to/snowglober/
.env
file at top of repo:
SNOWFLAKE_USERNAME="<value>"
SNOWFLAKE_PASSWORD="<value>"
SNOWFLAKE_ACCOUNT="<value>"
SNOWFLAKE_WAREHOUSE="<value>"
SNOWFLAKE_DATABASE="<value>"
SNOWFLAKE_SCHEMA="<value>"
SNOWFLAKE_ROLE="<value>"
*.egg-info*
.env*
.venv*
__pycache__/
terraform.tfvars
.terraform*
To run the code, run
python snowglober/main.py
To test the code, run
python tests/test_snowflake_connector.py