### Install Titan Core from PyPi (MacOS, Linux) Source: https://github.com/titan-systems/titan/blob/main/docs/getting-started.md Installs the Titan Core Python package using pip within a virtual environment. This is the standard installation method for Unix-like systems. ```sh python -m venv .venv source .venv/bin/activate python -m pip install titan-core ``` -------------------------------- ### Install Titan Core from PyPi (Windows) Source: https://github.com/titan-systems/titan/blob/main/docs/getting-started.md Installs the Titan Core Python package using pip within a virtual environment on Windows. This method uses Windows-specific activation commands. ```bat python -m venv .venv .\.venv\Scripts\activate python -m pip install titan-core ``` -------------------------------- ### Titan CLI: Show Help Message Source: https://github.com/titan-systems/titan/blob/main/docs/getting-started.md Displays the main help message for the Titan CLI, outlining available commands and options for managing Snowflake environments. ```sh titan --help ``` -------------------------------- ### Configure and Plan Snowflake Resources with Python Source: https://github.com/titan-systems/titan/blob/main/docs/getting-started.md Demonstrates how to define Snowflake resources (Role, Warehouse, Grant) using Python objects and then generate a deployment plan using the Titan Blueprint. Requires snowflake-connector-python. ```python 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) # 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 CLI: Export Snowflake Resources to YAML Source: https://github.com/titan-systems/titan/blob/main/docs/getting-started.md Exports existing Snowflake resources (e.g., warehouse, grant, role) into a YAML configuration file. This is useful for generating a starting configuration for an existing environment. ```sh titan export \ --resource=warehouse,grant,role \ --out=titan.yml ``` -------------------------------- ### Titan CLI: Apply Configuration from YAML Source: https://github.com/titan-systems/titan/blob/main/docs/getting-started.md Applies a Snowflake resource configuration defined in a YAML file to your Snowflake account. This involves creating a config file, setting environment variables, and running the `plan` and `apply` commands. ```sh # Create a resource config file 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 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 ``` -------------------------------- ### Deploy Snowflake Resources with Titan GitHub Action Source: https://github.com/titan-systems/titan/blob/main/docs/getting-started.md This YAML configuration demonstrates how to use the Titan Core GitHub Action to automate Snowflake resource deployments. It specifies the workflow trigger, the runner, and the action's inputs like `run-mode`, `resource-path`, `allowlist`, and `dry-run`, along with necessary environment variables for Snowflake authentication. ```yaml -- .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 CLI: Run via Python Module Source: https://github.com/titan-systems/titan/blob/main/docs/getting-started.md Executes Titan CLI commands using the Python module syntax. This provides an alternative way to run Titan commands, especially when managing Python environments. ```sh python -m titan plan --config titan.yml ``` -------------------------------- ### Configure Snowflake Service with YAML Source: https://github.com/titan-systems/titan/blob/main/docs/resources/service.md Provides an example of defining a Snowflake Service configuration using YAML. This format is often used for declarative service setup and management. ```yaml services: - name: some_service compute_pool: some_compute_pool stage: @tutorial_stage yaml_file_stage_path: echo_spec.yaml specification: FROM SPECIFICATION $$some_specification$$ external_access_integrations: - some_integration auto_resume: true min_instances: 1 max_instances: 2 query_warehouse: some_warehouse tags: key: value comment: This is a sample service. ``` -------------------------------- ### Create Snowflake Share (Python) Source: https://github.com/titan-systems/titan/blob/main/docs/resources/share.md Example of creating a Snowflake Share resource using Python, defining its name and comment. ```python share = Share( name="some_share", comment="This is a snowflake share." ) ``` -------------------------------- ### GrantOnAll YAML Configuration Source: https://github.com/titan-systems/titan/blob/main/docs/resources/grant_on_all.md Shows an example of configuring grants on all resources using YAML format. ```YAML grants_on_all: - priv: SELECT on_all_tables_in_schema: someschema to: somerole ``` -------------------------------- ### Install Titan Core (Windows) Source: https://github.com/titan-systems/titan/blob/main/README.md Installs the Titan Core Python package using pip within a virtual environment on Windows. This command sequence sets up the necessary environment for Windows users. ```bat python -m venv .venv .\.venv\Scripts\activate python -m pip install titan-core ``` -------------------------------- ### Define Snowflake Share (YAML) Source: https://github.com/titan-systems/titan/blob/main/docs/resources/share.md Example of defining a Snowflake Share resource using YAML, specifying its name and comment. ```yaml shares: - name: some_share comment: This is a snowflake share. ``` -------------------------------- ### OAuthSecret Configuration Examples Source: https://github.com/titan-systems/titan/blob/main/docs/resources/oauth_secret.md Demonstrates how to define an OAuthSecret using Python and YAML, covering client credentials and authorization code grant flows for managing OAuth secrets. ```Python secret = OAuthSecret( name="some_secret", api_authentication="some_security_integration", oauth_scopes=["scope1", "scope2"], comment="some_comment", owner="SYSADMIN", ) secret = OAuthSecret( name="another_secret", api_authentication="some_security_integration", oauth_refresh_token="34n;vods4nQsdg09wee4qnfvadH", oauth_refresh_token_expiry_time="2049-01-06 20:00:00", comment="some_comment", owner="SYSADMIN", ) ``` ```YAML secrets: - name: some_secret secret_type: OAUTH2 api_authentication: some_security_integration oauth_scopes: - scope1 - scope2 comment: some_comment owner: SYSADMIN - name: another_secret secret_type: OAUTH2 api_authentication: some_security_integration oauth_refresh_token: 34n;vods4nQsdg09wee4qnfvadH oauth_refresh_token_expiry_time: 2049-01-06 20:00:00 comment: some_comment owner: SYSADMIN ``` -------------------------------- ### ResourceMonitor Configuration in YAML Source: https://github.com/titan-systems/titan/blob/main/docs/resources/resource_monitor.md Provides a YAML configuration example for defining resource monitors, including name, credit quota, frequency, timestamps, and users to notify. ```yaml resource_monitors: - name: some_resource_monitor credit_quota: 1000 frequency: DAILY start_timestamp: "2049-01-01 00:00" end_timestamp: "2049-12-31 23:59" notify_users: - user1 - user2 ``` -------------------------------- ### Create External Access Integration (Python) Source: https://github.com/titan-systems/titan/blob/main/docs/resources/external_access_integration.md Example of creating an ExternalAccessIntegration resource using Python. This involves specifying the integration name, allowed network rules, and whether it is enabled. ```python external_access_integration = ExternalAccessIntegration( name="some_external_access_integration", allowed_network_rules=["rule1", "rule2"], enabled=True ) ``` -------------------------------- ### GrantOnAll Python Examples Source: https://github.com/titan-systems/titan/blob/main/docs/resources/grant_on_all.md Demonstrates how to create GrantOnAll objects in Python for granting privileges on all schemas or tables/views within a database or schema. ```Python grant_on_all = GrantOnAll( priv="CREATE TABLE", on_all_schemas_in_database="somedb", to="somerole", ) grant_on_all = GrantOnAll( priv="CREATE VIEW", on_all_schemas_in=Database(name="somedb"), to="somerole", ) # Schema Object Privs: grant_on_all = GrantOnAll( priv="SELECT", on_all_tables_in_schema="someschema", to="somerole", ) grant_on_all = GrantOnAll( priv="SELECT", on_all_views_in_database="somedb", to="somerole", ) ``` -------------------------------- ### Configure Snowflake User (YAML) Source: https://github.com/titan-systems/titan/blob/main/docs/resources/user.md Example of defining a Snowflake user configuration in YAML format, including user properties. This illustrates declarative user management. ```yaml users: - name: some_user owner: USERADMIN email: some.user@example.com type: PERSON ``` -------------------------------- ### Create External Access Integration (YAML) Source: https://github.com/titan-systems/titan/blob/main/docs/resources/external_access_integration.md Example of defining an ExternalAccessIntegration resource in YAML format. This configuration includes the integration name, allowed network rules, and its enabled status. ```yaml external_access_integrations: - name: some_external_access_integration allowed_network_rules: - rule1 - rule2 enabled: true ``` -------------------------------- ### Install Titan Core (MacOS/Linux) Source: https://github.com/titan-systems/titan/blob/main/README.md Installs the Titan Core Python package using pip within a virtual environment. This is the recommended method for macOS and Linux users to get started with the tool. ```sh python -m venv .venv source .venv/bin/activate python -m pip install titan-core ``` -------------------------------- ### Create Snowflake Service with Python Source: https://github.com/titan-systems/titan/blob/main/docs/resources/service.md Demonstrates how to instantiate and configure a Snowflake Service object using the Python SDK. It covers essential parameters like name, compute pool, specification, and instance management. ```python service = Service( name="some_service", compute_pool="some_compute_pool", stage="@tutorial_stage", yaml_file_stage_path="echo_spec.yaml", specification="FROM SPECIFICATION $$some_specification$$", external_access_integrations=["some_integration"], auto_resume=True, min_instances=1, max_instances=2, query_warehouse="some_warehouse", tags={"key": "value"}, comment="This is a sample service." ) ``` -------------------------------- ### Python Example: Define and Plan Snowflake Resources Source: https://github.com/titan-systems/titan/blob/main/README.md Demonstrates how to define Snowflake resources like Roles and Warehouses using Python objects and create a Blueprint for deployment. It shows how to configure connection parameters and validate the plan against a Snowflake account. ```python 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 ``` -------------------------------- ### Titan Ignore File Example Source: https://github.com/titan-systems/titan/blob/main/docs/titan-core-github-action.md An example of a `.titanignore` file, which uses gitignore syntax to specify files or directories that Titan should exclude from processing when scanning a resource path. ```Git Ignore # .titanignore # Ignore dbt config dbt_project.yml ``` -------------------------------- ### Titan CLI: Plan and Apply Configuration Source: https://github.com/titan-systems/titan/blob/main/README.md Shows how to create a Titan YAML configuration file and use the Titan CLI to generate a plan and apply it to a Snowflake account. Includes setting necessary Snowflake environment variables. ```shell # Create a resource config file 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 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 ``` -------------------------------- ### Python Blueprint Initialization and Usage Source: https://github.com/titan-systems/titan/blob/main/docs/blueprint.md Demonstrates how to initialize a Blueprint object in Python with resources, run mode, allowlist, and dry_run settings. It also shows how to generate a plan and apply it using a Snowflake session. ```Python from titan.blueprint import Blueprint from titan.resources import Database, Schema # Assuming 'session' is an established SnowflakeConnection object session = ... bp = Blueprint( run_mode='create-or-update', resources=[ Database('my_database'), Schema('my_schema', database='my_database'), ], allowlist=["database", "schema"], dry_run=False, ) plan = bp.plan(session) bp.apply(session, plan) ``` -------------------------------- ### Email Notification Integration Configuration (Python, YAML) Source: https://github.com/titan-systems/titan/blob/main/docs/resources/email_notification_integration.md Demonstrates how to define and configure an email notification integration in Snowflake. This includes specifying the integration's name, whether it is enabled, a list of allowed email recipients, and an optional comment. The Python example shows object instantiation, while the YAML example represents the configuration structure. ```python email_notification_integration = EmailNotificationIntegration( name="some_email_notification_integration", enabled=True, allowed_recipients=["user1@example.com", "user2@example.com"], comment="Example email notification integration" ) ``` ```yaml email_notification_integrations: - name: some_email_notification_integration enabled: true allowed_recipients: - user1@example.com - user2@example.com comment: "Example email notification integration" ``` -------------------------------- ### Blueprint Methods Documentation Source: https://github.com/titan-systems/titan/blob/main/docs/blueprint.md Documents the core methods of the Blueprint class: `plan` for analyzing Snowflake state and `apply` for executing changes. It also covers the `add` method for incrementally adding resources. ```APIDOC Blueprint Methods: plan(session) - Analyzes your Snowflake account to determine differences from the configuration. - Identifies resources to be added, changed, or removed. - Parameters: - session (`SnowflakeConnection`): The session object for connecting to Snowflake. - Returns: - `list[ResourceChange]`: A list of changes required for the Snowflake account. apply(session, [plan]) - Executes the SQL commands necessary to update your Snowflake account based on the generated plan. - Parameters: - session (`SnowflakeConnection`): The session object for connecting to Snowflake. - plan (`list[ResourceChange]`, optional): The list of changes to apply. If omitted, the plan is generated automatically. - Returns: - `list[str]`: A list of SQL commands that were executed. add(resource: Resource) - Allows adding a resource to the blueprint. - Alternate uses: - `add(resource_1, resource_2, ...)` - `add([resource_1, resource_2, ...])` ``` -------------------------------- ### Create SessionPolicy in Python Source: https://github.com/titan-systems/titan/blob/main/docs/resources/session_policy.md Example of creating a SessionPolicy object in Python with specified idle timeouts and a comment. ```python session_policy = SessionPolicy( name="some_session_policy", session_idle_timeout_mins=30, session_ui_idle_timeout_mins=10, comment="Policy for standard users." ) ``` -------------------------------- ### Define ParquetFileFormat in YAML Source: https://github.com/titan-systems/titan/blob/main/docs/resources/parquet_file_format.md Example of defining a Parquet file format in YAML, mirroring the properties available for configuration. ```yaml file_formats: - name: some_file_format owner: SYSADMIN compression: AUTO binary_as_text: true trim_space: false replace_invalid_characters: false null_if: - NULL comment: This is a Parquet file format. ``` -------------------------------- ### YAML Vars Configuration Example Source: https://github.com/titan-systems/titan/blob/main/docs/blueprint.md Shows how to define variables within a YAML configuration file (`titan.yml`) using double curly braces for templating resource names. ```YAML --- titan.yml ... databases: - name: "db_{{ var.fruit }}" ``` -------------------------------- ### Create Snowflake Database in Python Source: https://github.com/titan-systems/titan/blob/main/docs/resources/database.md Demonstrates how to instantiate a Database object in Python with various configuration parameters like name, owner, data retention, and tags. ```python database = Database( name="some_database", transient=True, owner="SYSADMIN", data_retention_time_in_days=7, max_data_extension_time_in_days=28, default_ddl_collation="utf8", tags={"project": "research", "priority": "high"}, comment="This is a database." ) ``` -------------------------------- ### Reusable Schema Configuration Source: https://github.com/titan-systems/titan/blob/main/docs/blueprint.md Demonstrates creating a reusable schema configuration that can be applied across different environments or for multiple users. This setup allows for consistent schema definitions that can be targeted using the `--schema` flag during `titan apply`. ```yaml scope: SCHEMA database: DEV tables: ... views: ... procedures: ... ``` -------------------------------- ### Define Session Policies in YAML Source: https://github.com/titan-systems/titan/blob/main/docs/resources/session_policy.md Example of defining session policies using YAML, specifying idle timeouts and comments. ```yaml session_policies: - name: some_session_policy session_idle_timeout_mins: 30 session_ui_idle_timeout_mins: 10 comment: Policy for standard users. ``` -------------------------------- ### Create DatabaseRole (Python) Source: https://github.com/titan-systems/titan/blob/main/docs/resources/database_role.md Demonstrates how to instantiate a DatabaseRole object in Python. This involves specifying the role's name, associated database, owner, optional tags, and a descriptive comment. ```python database_role = DatabaseRole( name="some_database_role", database="some_database", owner="USERADMIN", tags={"department": "finance"}, comment="This role is for database-specific access control." ) ``` -------------------------------- ### FutureGrant YAML Configuration Source: https://github.com/titan-systems/titan/blob/main/docs/resources/future_grant.md Provides an example of how to define future grants for Snowflake resources using YAML format. ```YAML future_grants: - priv: SELECT on_future_tables_in_schema: someschema to: somerole ``` -------------------------------- ### API Integration Configuration (YAML) Source: https://github.com/titan-systems/titan/blob/main/docs/resources/api_integration.md Example configuration for an API integration in YAML format, specifying parameters for AWS API Gateway. ```yaml api_integrations: - name: some_api_integration api_provider: AWS_API_GATEWAY api_aws_role_arn: "arn:aws:iam::123456789012:role/MyRole" enabled: true api_allowed_prefixes: ["/prod/", "/dev/"] api_blocked_prefixes: ["/test/"] api_key: "ABCD1234" comment: "Example API integration" ``` -------------------------------- ### YAML Glue Catalog Integration Configuration Source: https://github.com/titan-systems/titan/blob/main/docs/resources/glue_catalog_integration.md Provides a YAML configuration example for setting up a Glue Catalog Integration in Snowflake. This format is often used for declarative infrastructure or configuration management. ```yaml catalog_integrations: - name: some_catalog_integration table_format: ICEBERG glue_aws_role_arn: arn:aws:iam::123456789012:role/SnowflakeAccess glue_catalog_id: some_glue_catalog_id catalog_namespace: some_namespace enabled: true glue_region: us-west-2 comment: Integration for AWS Glue with Snowflake. ```