Skip to content

rittmananalytics/snowglober

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project curator: Amir Jaber ( github, linkedin, email: amir@rittmananalytics.com )

snowglober

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:

  1. extract all objects in Snowflake which map to a Terraform resource.
  2. create terraform files with resources made to map to each live object.

Usage

environment variables in .tfvars

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.

  1. Ensure your environment variables match (case-insensitively) with the variables listed in the project's Environment Variables section.

  2. Run Snowglober. It creates the terraform.tfvars file based on your environment variables.

  3. Run your usual Terraform commands. The terraform.tfvars file is automatically included in these commands, for example, when you run terraform apply.

Architecture

snowglober's .tf file generation workflow

  1. set up provider and variable files; variables contain creds and are populated from .env vars
  2. query snowflake for all objects of each resource type
  3. generate .tf files with resources - at this stage only required properties are defined
  4. run terraform init
  5. run terraform import for each resource
  6. extract remaining (and optional) properties from the generated .tfstate file
  7. update the resources in the .tf files with the remaining properties

Dev

This package is open source in nature, under the MIT license. Anyone who wants to contribute is free to do so, just reach out!

Install in dev mode

pip install -e /path/to/snowglober/   

Environment variables

.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>"

Recommended .gitignore

*.egg-info*
.env*
.venv*
__pycache__/
terraform.tfvars
.terraform*

Run

To run the code, run

python snowglober/main.py

Unit tests

To test the code, run

python tests/test_snowflake_connector.py

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages