Skip to content

Pulumi program template that stands up a database and schema in Snowflake

Notifications You must be signed in to change notification settings

pulumi-demos/snowflake-basic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Snowflake-basic

This program is an example for implementing Snowflake resources in an additive deployment manner.
It orchestrates which infrastructure components are created during a pulumi up run by evaluating configuration-driven feature flags.

The program intentionally contains no Snowflake resource definitions.
All infrastructure is provisioned through reusable ComponentResources.


Purpose

__main__.py acts as the composition and control layer for the deployment.

It is responsible for:

  • Reading Pulumi configuration
  • Enabling or disabling components
  • Wiring component outputs to downstream components
  • Exporting stack outputs

Responsibilities

  • Evaluate config flags to determine which components run
  • Instantiate DatabaseComponent and/or SchemaComponent
  • Support additive deployments across multiple runs
  • Keep infrastructure logic isolated inside components


Execution Model

Each component is gated behind a Pulumi configuration boolean with the same name as the component.

Config Key Behavior
db_component = true Creates a Snowflake database
schema_component = true Creates a schema in a database

Components can be enabled independently in different pulumi up runs.


Configuration

Required / Optional Config Values

Key Type Required Description
db_component bool No Enable database creation
schema_component bool No Enable schema creation
database_name string Conditional Target database name
schema_name string Conditional Target schema name

Program Flow

  1. Read Pulumi configuration
  2. Evaluate db_component flag
  3. Create database if enabled
  4. Evaluate schema_component flag
  5. Create schema if enabled
  6. Export relevant outputs

Code Structure

cfg = Config()

if enabled("db_component"):
    DatabaseComponent(...)

if enabled("schema_component"):
    SchemaComponent(...)

Example Usage

pulumi config set DatabaseComponent true
pulumi config set SchemaComponent false
pulumi config set databaseName DEMO_DB

pulumi up

Add Schema in a Later Run

pulumi config set DatabaseComponent false
pulumi config set SchemaComponent true
pulumi config set schemaName ANALYTICS

pulumi up

About

Pulumi program template that stands up a database and schema in Snowflake

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages