Skip to content

feat: Add SnowDDL to Terraform generator command [v0.3] - #25

Open
db-tycoon-stephen wants to merge 1 commit into
mainfrom
feature/terraform-generator
Open

feat: Add SnowDDL to Terraform generator command [v0.3]#25
db-tycoon-stephen wants to merge 1 commit into
mainfrom
feature/terraform-generator

Conversation

@db-tycoon-stephen

Copy link
Copy Markdown
Contributor

Summary

Adds uv run generate-terraform command that converts SnowDDL YAML configurations into Terraform HCL files with import blocks for seamless migration to Terraform-managed infrastructure.

Closes #24

Features

  • Full config coverage: Converts all SnowDDL config types to Terraform resources

    • Warehouses → snowflake_warehouse
    • Users → snowflake_user
    • Tech/Business Roles → snowflake_account_role
    • Grants → snowflake_grant_privileges_to_account_role
    • Network/Auth/Password/Session Policies → respective policy resources
    • Resource Monitors → snowflake_resource_monitor
    • Databases/Schemas → snowflake_database, snowflake_schema
  • Import blocks: Generates Terraform 1.5+ import blocks for all existing resources

  • Organized output: Creates structured file layout (main.tf, variables.tf, etc.)

  • Grant expansion: Expands SnowDDL's compact grant format into individual Terraform resources

Usage

# Preview to stdout
uv run generate-terraform

# Generate to directory
uv run generate-terraform --output terraform/

# Then migrate with:
cd terraform/
terraform init
terraform plan    # Review imports
terraform apply   # Import existing resources

Example Output

SnowDDL input:

MAIN_WAREHOUSE:
  auto_suspend: 60
  size: X-Small
  resource_monitor: DEV_MONITOR

Terraform output:

resource "snowflake_warehouse" "main_warehouse" {
  name             = "MAIN_WAREHOUSE"
  warehouse_size   = "XSMALL"
  auto_suspend     = 60
  auto_resume      = true
  resource_monitor = snowflake_resource_monitor.dev_monitor.name
}

import {
  to = snowflake_warehouse.main_warehouse
  id = "MAIN_WAREHOUSE"
}

Test plan

  • All 22 new tests pass
  • Existing 333 tests still pass
  • Command works from project root
  • Output files are valid HCL structure
  • Import blocks generated correctly

🤖 Generated with Claude Code

Add `uv run generate-terraform` command that converts SnowDDL YAML
configurations into Terraform HCL files with import blocks for
seamless migration to Terraform-managed infrastructure.

Features:
- Converts all SnowDDL config types to Terraform resources
- Generates import blocks for existing resources
- Supports warehouses, users, roles, grants, policies, monitors
- Outputs organized file structure (main.tf, variables.tf, etc.)
- Handles complex grant expansion from SnowDDL compact format

Usage:
  uv run generate-terraform                      # Print to stdout
  uv run generate-terraform --output terraform/  # Write to directory

Closes #24

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add SnowDDL to Terraform generator command

1 participant