Titan Core Documentation
repository·main·Indexed 19 days ago
https://github.com/titan-systems/titanA declarative infrastructure-as-code (IaC) tool for Snowflake designed to replace manual SQL scripts and tools like Terraform. Titan Core allows users to provision and secure Snowflake resources—including users, roles, schemas, databases, and warehouses—via a Python API, a CLI using YAML configurations, or a dedicated GitHub Action. It features dynamic role switching, no state file dependency, and support for variable injection and scoped management at the database or schema level.
What's inside Titan Core
- Titan Core is a declarative infrastructure-as-code (IaC) tool specifically designed for Snowflake. It allows you to provision, deploy, and secure Snowflake resources (such as users, roles, schemas, databases, integrations, pipes, stages, functions, and stored procedures) using simple, repeatable configurations instead of manual SQL scripts. It is designed as a replacement for tools like Terraform, Schemachange, or Permifrost, offering faster execution and a git-based workflow.
Titan Core Documentation Overview
mainTitan Core is a Snowflake infrastructure-as-code tool. The documentation is organized into several key areas to help you manage Snowflake resources:
- Getting Started: Initial setup and first steps.
- Working With Resources: Detailed guidance on managing Snowflake objects.
- Blueprint: Information on using Blueprints to group and manage resource sets.
- GitHub Action: Instructions for integrating Titan into CI/CD pipelines.
- Resource Reference: A comprehensive list of supported Snowflake resources (e.g.,
Database,Warehouse,Table,Role,Storage Integrations, etc.).
Configure ExternalAccessIntegration
mainUse
ExternalAccessIntegrationto enable code within Snowflake functions and stored procedures to utilize secrets and establish connections with external networks. This resource defines whichNetworkRulesand authentication secrets are accessible to the integration.To configure this in Titan, you can either instantiate a Python object or define it in a YAML configuration file.
external_access_integration = ExternalAccessIntegration( name="some_external_access_integration", allowed_network_rules=["rule1", "rule2"], enabled=True )Handling quoted identifiers
mainTitan automatically infers when a Snowflake identifier requires quoting. It is recommended to avoid manually quoting identifiers unless Titan's automatic inference fails for a specific edge case.Compare Titan Core with other Snowflake IaC tools
mainTitan Core is a declarative, Python-based Snowflake infrastructure-as-code tool. It differs from other tools in several key ways:
- vs Terraform: Unlike the Snowflake provider for Terraform which is limited to 1 role per provider, Titan Core supports dynamic role switching, automatically detecting and switching to the required role for a change. It also has no state file dependency, providing more accurate plans and eliminating stale state issues.
- vs Schemachange: While Schemachange is an imperative migration tool requiring manual SQL scripts, Titan Core is declarative. You define the desired state, and Titan handles the implementation details.
- vs Permifrost: Titan Core is designed for high performance, running in seconds even for complex environments, whereas Permifrost can be significantly slower.
- vs SnowDDL: SnowDDL uses a specific 3-tier role hierarchy model; Titan Core is a more general-purpose declarative tool.
Manage Snowflake Sequences with Titan
mainTitan allows you to manage Snowflake Sequences—objects that generate numeric values—using either Python objects or YAML configuration. This enables infrastructure-as-code management of sequence creation and configuration.Define a Snowflake Secret
mainA
Secretdefines a set of sensitive data used for authentication or other purposes within Snowflake. You can define secrets using either Python objects or YAML configuration. Thenameandtypefields are required.secret = Secret( name="some_secret", type="OAUTH2", api_authentication="some_security_integration", oauth_scopes=["scope1", "scope2"], oauth_refresh_token="some_refresh_token", oauth_refresh_token_expiry_time="some_expiry_time", username="some_username", password="some_password", secret_string="some_secret_string", comment="some_comment", owner="SYSADMIN", )Use the Grant resource to manage Snowflake privileges
mainThe
Grantresource represents the assignment of privileges on a specific Snowflake resource to a role. You can define grants for global account privileges, warehouse privileges, schema privileges, or table privileges using either Python or YAML.Key Fields
priv(string, required): The specific privilege to grant (e.g.,'SELECT','INSERT','CREATE TABLE','OPERATE').on(string or [Resource], required): The target resource. This can be a string (like'ACCOUNT') or a specific resource object (likeWarehouse(name="foo")).to(string or [Role], required): The role receiving the privileges.grant_option(bool): Iftrue, the grantee can grant these privileges to other roles. Defaults toFalse.owner(string or [Role]): The role that owns the grant. Defaults to'SYSADMIN'.
# Example: Granting SELECT on a table to a role grant = Grant(priv="SELECT", on_table="sometable", to="somerole")Manage GCS storage integrations with GCSStorageIntegration
mainUse the
GCSStorageIntegrationresource to manage the integration of Google Cloud Storage (GCS) as an external stage in Snowflake. This allows you to define which GCS locations are accessible for data storage and which are explicitly blocked.gcs_storage_integration = GCSStorageIntegration( name="some_gcs_storage_integration", enabled=True, storage_allowed_locations=['gcs://bucket/path/'], storage_blocked_locations=['gcs://bucket/blocked_path/'] )Use variables (vars) in Titan configurations
mainTitan supports dynamic configurations using variables (
vars). You can define variables in YAML or Python and inject values at runtime.YAML Syntax
Use double curly braces
{{ var.name }}for Jinja-style templating. You can define expected variables and their defaults using the top-levelvars:key.vars: - name: color type: string - name: fruit type: string default: apple databases: - name: "db_{{ var.color }}_{{ var.fruit }}"Python Syntax
You can use the
titan.varmodule or Jinja-style strings:from titan import var from titan.resources import Database # Using the var module db1 = Database(name=var.db1_name) # Using Jinja-style strings db2 = Database(name="db_{{ var.db2_name }}")Injecting Variable Values
- CLI Flag: Pass a JSON string via
--vars.titan plan --config titan.yml --vars '{"fruit": "banana"}' - Environment Variables: Use variables starting with
TITAN_VAR_in uppercase.export TITAN_VAR_FRUIT="peach"titan plan --config titan.yml - Python Blueprint: Pass a dictionary to the
varsparameter in theBlueprintconstructor.
# Example YAML with vars vars: - name: color type: string - name: fruit type: string default: apple databases: - name: "db_{{ var.color }}_{{ var.fruit }}"- CLI Flag: Pass a JSON string via
Establish relationships between resources
mainYou can link resources together to define relationships (e.g., assigning a role to a user) using two primary methods:
- Pass by Instance: Pass the actual resource object directly to another resource's parameter. This is the clearest and most direct method.
- Pass by Name: Pass the resource's name as a string. This is useful for serialization or specific configuration requirements.
Manage Snowflake ExternalStages
mainTheExternalStageresource manages external stages in Snowflake, which are used to reference external storage locations (e.g., S3, Azure Blob, GCS). You can define these resources using either Python objects or YAML configuration.