Titan
Titan Core - Snowflake infrastructure-as-code. Provision environments, automate deploys, CI/CD. Manage RBAC, users, roles, and data access. Declarative Python Resource API. Change Management tool for the Snowflake data warehouse.
Install / Use
/learn @Titan-Systems/TitanREADME
titan core - Snowflake infrastructure as code
Titan Core helps you provision, deploy, and secure resources in Snowflake. It replaces tools like Terraform, Schemachange, or Permifrost.
Deploy any Snowflake resource, including users, roles, schemas, databases, integrations, pipes, stages, functions, stored procedures, and more. Convert adhoc, bug-prone SQL management scripts into simple, repeatable configuration.
Titan Core is for:
- DevOps engineers looking to automate and manage Snowflake infrastructure.
- Analytics engineers working with dbt who want to manage Snowflake resources without macros.
- Data platform teams who need to reliably manage Snowflake with CI/CD.
- Organizations that prefer a git-based workflow for infrastructure management.
- Teams seeking to replace Terraform for Snowflake-related tasks.
╔══════════╗ ╔═══════════╗
║ CONFIG ║ ║ SNOWFLAKE ║
╚══════════╝ ╚═══════════╝
┏━━━━━━━━━━━┓ ┏━━━━━━━━━━━┓
┌─┫ WAREHOUSE ┣─────┐ ┌─┫ WAREHOUSE ┣───────────┐
│ ┗━━━━━━━━━━━┛ │ ALTER │ ┗━━━━━━━━━━━┛ │
│ name: ETL │─────┐ ┌─ WAREHOUSE ─▶│ name: ETL │
│ auto_suspend: 60 │ │ │ │ auto_suspend: 300 -> 60 │
└───────────────────┘ ╔══▼═══════════╩═╗ └─────────────────────────┘
║ ║
║ TITAN CORE ║
┏━━━━━━┓ ║ ║ ┏━━━━━━┓
┌─┫ ROLE ┣──────────┐ ╚══▲═══════════╦═╝ ┌─┫ ROLE ┣────────────────┐
│ ┗━━━━━━┛ │ │ │ │ ┗━━━━━━┛ │
│ name: TRANSFORMER │─────┘ └─ CREATE ────▶│ name: TRANSFORMER │
└───────────────────┘ ROLE └─────────────────────────┘
Key Features
-
Declarative » Generates the right SQL to make your config and account match
-
Comprehensive » Nearly every Snowflake resource is supported
-
Flexible » Write resource configuration in YAML or Python
-
Fast » Titan Core runs 50-90% faster than Terraform and Permifrost
-
Migration-friendly » Generate config automatically with the export CLI
Open Source
This project is licensed under the Apache 2.0 License - see LICENSE for details. The source code for Titan Core is available on Github.
Documentation
You can find comprehensive Titan Core documentation on GitBook.
Getting Started
If you're new, the best place to start is with the Python package.
Install from PyPi (MacOS, Linux)
python -m venv .venv
source .venv/bin/activate
python -m pip install titan-core
Install from PyPi (Windows)
python -m venv .venv
.\.venv\Scripts\activate
python -m pip install titan-core
Python example
import os
import snowflake.connector
from titan.blueprint import Blueprint, print_plan
from titan.resources import Grant, Role, Warehouse
# Configure resources by instantiating Python objects.
role = Role(name="transformer")
warehouse = Warehouse(
name="transforming",
warehouse_size="large",
auto_suspend=60,
)
usage_grant = Grant(priv="usage", to=role, on=warehouse)
# Titan compares your config to a Snowflake account. Create a Snowflake
# connection to allow Titan to connect to your account.
connection_params = {
"account": os.environ["SNOWFLAKE_ACCOUNT"],
"user": os.environ["SNOWFLAKE_USER"],
"password": os.environ["SNOWFLAKE_PASSWORD"],
"role": "SYSADMIN",
}
session = snowflake.connector.connect(**connection_params)
# Create a Blueprint and pass your resources into it. A Blueprint helps you
# validate and deploy a set of resources.
bp = Blueprint(resources=[
role,
warehouse,
usage_grant,
])
# Blueprint works like Terraform. Calling plan(...) will compare your config
# to the state of your Snowflake account and return a list of changes.
plan = bp.plan(session)
print_plan(plan) # =>
"""
» titan core
» Plan: 4 to add, 0 to change, 0 to destroy.
+ urn::ABCD123:warehouse/transforming {
+ name = "transforming"
+ owner = "SYSADMIN"
+ warehouse_type = "STANDARD"
+ warehouse_size = "LARGE"
...
}
+ urn::ABCD123:role/transformer {
+ name = "transformer"
+ owner = "USERADMIN"
+ tags = None
+ comment = None
}
+ urn::ABCD123:grant/TRANSFORMER?priv=USAGE&on=warehouse/TRANSFORMING {
+ priv = "USAGE"
+ on = "transforming"
+ on_type = "WAREHOUSE"
+ to = TRANSFORMER
...
}
"""
# Calling apply(...) will convert your plan into the right set of SQL commands
# and run them against your Snowflake account.
bp.apply(session, plan) # =>
"""
[TITAN_USER:SYSADMIN] > USE SECONDARY ROLES ALL
[TITAN_USER:SYSADMIN] > CREATE WAREHOUSE TRANSFORMING warehouse_type = STANDARD ...
[TITAN_USER:SYSADMIN] > USE ROLE USERADMIN
[TITAN_USER:USERADMIN] > CREATE ROLE TRANSFORMER
[TITAN_USER:USERADMIN] > USE ROLE SYSADMIN
[TITAN_USER:SYSADMIN] > GRANT USAGE ON WAREHOUSE transforming TO TRANSFORMER
"""
Using the CLI
You can use the CLI to generate a plan, apply a plan, or export resources. To use the CLI, install the Python package and call python -m titan from the command line.
The CLI allows you to plan and apply a Titan Core YAML config. You can specify a single input file or a directory of configs.
In addition to plan and apply, the CLI also allows you to export resources. This makes it easy to generate a config for an existing Snowflake environment.
To connect with Snowflake, the CLI uses environment variables. The following are supported:
SNOWFLAKE_ACCOUNTSNOWFLAKE_USERSNOWFLAKE_PASSWORDSNOWFLAKE_DATABASESNOWFLAKE_SCHEMASNOWFLAKE_ROLESNOWFLAKE_WAREHOUSESNOWFLAKE_MFA_PASSCODESNOWFLAKE_AUTHENTICATOR
If using key-pair auth instead of password, use the following environment variables in place of SNOWFLAKE_PASSWORD:
SNOWFLAKE_PRIVATE_KEY_PATHPRIVATE_KEY_PASSPHRASE(if using encrypted key)
Note: the value for SNOWFLAKE_AUTHENTICATOR should be set to SNOWFLAKE_JWT when using key-pair auth.
CLI Example
Show the help message
titan --help
# Usage: titan [OPTIONS] COMMAND [ARGS]...
#
# titan core helps you manage your Snowflake environment.
#
# Options:
# --help Show this message and exit.
#
# Commands:
# apply Apply a resource config to a Snowflake account
# connect Test the connection to Snowflake
# export Generate a resource config for existing Snowflake resources
# plan Compare a resource config to the current state of Snowflake
Apply a resource config to Snowflake
# Create a resource config file
cat <<EOF > titan.yml
roles:
- name: transformer
warehouses:
- name: transforming
warehouse_size: LARGE
auto_suspend: 60
grants:
- to_role: transformer
priv: usage
on_warehouse: transforming
EOF
# Set connection variables
export SNOWFLAKE_ACCOUNT="my-account"
export SNOWFLAKE_USER="my-user"
export SNOWFLAKE_PASSWORD="my-password"
# Generate a plan
titan plan --config titan.yml
# Apply the config
titan apply --config titan.yml
Export existing Snowflake resources to YAML.
titan export \
--resource=warehouse,grant,role \
--out=titan.yml
The Titan Core Python package installs the CLI script titan. You can alternatively use Python CLI module syntax if you need fine-grained control over the Python environment.
python -m titan plan --config titan.yml
Using the GitHub Action
The Titan Core GitHub Action allows you to automate the deployment of Snowflake resources using a git-based workflow.
GitHub Action Example
-- .github/workflows/titan.yml
name: Deploy to Snowflake with Titan
on:
push:
branches: [ main ]
paths:
- 'titan/**'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy to Snowflake
uses: Titan-Systems/titan-core-action@main
with:
run-mode: 'create-or-update'
resource-path: './titan'
allowlist: 'warehouse,role,grant'
dry-run: 'false'
env:
SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }}
SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
SNOWFLAKE_ROLE: ${{ secrets.SNOWFLAKE_ROLE }}
SNOWFLAKE_WAREHOUSE: ${{ secrets.SNOWFLAKE_WAREHOUSE }}
Titan Core Limitations
- Titan Core uses names as unique identifiers. Renaming a resource will create a new one.
- Titan Core is not an ORM. It's not built to replace tools like SQLAlchemy.
- Titan Core is under active development. Some resources are not yet supported.
titan core vs other tools
| Feature | Titan Core | Terraform | Schemachange | Permifrost | SnowDDL | |-----------------------------------------|------------|-----------|--------------| -----------| -------- | | Plan and Execute Changes | ✅ | ✅ | ❌ | ✅ | ✅ | | Declarative Config | ✅ | ✅ | ❌ | ✅ | ✅ | | No State File Dependency | ✅ | ❌ | ✅ | ✅ | ✅ | | Python-Based Definitions | ✅ | w/ CDKTF | ❌ | ❌ | ✅ | | SQL Support | ✅ | ❌ | ✅ | ❌ | ❌ | | Dynamic Role Switching
