Getting Started with Titan Core: Your Guide to Snowflake Infrastructure as Code

May 27, 2022 | Programming

Titan Core is a powerful tool designed to help you provision, deploy, and secure resources within Snowflake effortlessly. By utilizing Titan Core, you can replace cumbersome tools like Terraform, Schemachange, or Permifrost, and manage various Snowflake resources more effectively. In this guide, we’ll walk you through getting started with Titan Core, including installation, configuration, and troubleshooting.

What Titan Core Offers

  • Declarative Configurations: Generates the correct SQL to align your configurations with your Snowflake account.
  • Comprehensive Support: Almost every Snowflake resource is supported for management.
  • Pythonic Approach: Use Python seamlessly within your workflows.
  • Speed: Titan Core operates in seconds, even in complex environments.
  • Flexible Language Support: Write configurations in Python, YAML, or SQL.

Installing Titan Core

Let’s kick off your journey with Titan Core by installing the Python package. For this, you need to set up a virtual environment:

python -m venv .venv
# Activate the environment
# linux/mac:
source .venv/bin/activate
# windows:
..venv\Scripts\activate
python -m pip install titan-core

Using Titan Core

Once installed, you can start using it in various ways:

Using the Python Package

Configure resources by instantiating Python objects:

import os
import snowflake.connector
from titan.blueprint import Blueprint, print_plan
from titan.resources import Grant, Role, Warehouse

# Configure your resources
role = Role(name="transformer")
warehouse = Warehouse(
    name="transforming",
    warehouse_size="large",
    auto_suspend=60,
)
usage_grant = Grant(priv="usage", to=role, on=warehouse)

# Create a Snowflake connection
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 for deploying resources
bp = Blueprint(resources=[role, warehouse, usage_grant])
plan = bp.plan(session)
print_plan(plan)

Analogy: Building a House

Think of Titan Core as an architect for your Snowflake environment. Just as an architect plans out a house by arranging rooms, utilities, and materials on paper, Titan Core helps you define resources like roles and warehouses in your Snowflake account. The Blueprint acts as your architectural plan. When you call plan(…), it shows if there are any inconsistencies between your defined plans and the existing structures (or resources) in your Snowflake environment. Calling apply(…) is like construction, where Titan Core executes the plans into reality, building or adjusting your resources as specified.

Using the Command Line Interface (CLI)

The CLI allows you to manage your Snowflake resources directly from the command line:

python -m titan --help
# Sample YAML Configuration
cat < 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 up environment variables for Snowflake credentials
export SNOWFLAKE_ACCOUNT=my-account
export SNOWFLAKE_USER=my-user
export SNOWFLAKE_PASSWORD=my-password

# Generating and applying a plan
python -m titan plan --config titan.yml
python -m titan apply --config titan.yml

Troubleshooting Tips

If you encounter issues while using Titan Core, here are some common troubleshooting methods:

  • Check Environment Variables: Ensure that your environment variables for Snowflake credentials are set correctly.
  • Verify YAML Configurations: Ensure your YAML configurations follow proper syntax and structure.
  • Consult the Documentation: The Titan Core documentation provides comprehensive information that can be very helpful.
  • Reach Out for Assistance: For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Get started with Titan Core today, and take control of your Snowflake infrastructure with confidence!

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox