Terraform for Snowflake – add boolean column with default true or default false

The documentation of chanzuckerberg provider might not be very clear about specifying default for a column, so let me present a piece of working code:

resource "snowflake_table" "this" {
  for_each        = var.tables
  database        = "${var.db}_${upper(var.env)}"
  schema          = var.raw_data_schema
  name            = each.value
  comment         = "Table for events from ${each.key} topic"

  column {
    name     = "ID"
    type     = "NUMBER(38,0)"
    nullable = true

    identity {
      start_num = 1
      step_num  = 1
    }
  }

  column {
    ...
  }

  column {
    name     = "DELETED"
    type     = "BOOLEAN"
    nullable = true

    default {
      constant = "false"
    }
  }
}

Leave a comment