Back to changelog
New
•2 minute read

Snowflake: Storage Lifecycle Policies and New Schema Attributes

Atlas now manages Snowflake storage lifecycle policies with the new storage_lifecycle_policy block, and the schema block takes new attributes for logging, data compaction, Iceberg collation, object visibility, classification, and contacts.

The new storage_lifecycle_policy block declares a Snowflake storage lifecycle policy in a schema, with an as body that selects the rows to expire, or to archive in archive_tier for archive_for_days when both are set. The schema block also takes new attributes for logging, data compaction, Iceberg collation, object visibility, classification, and contacts.

Storage Lifecycle Policies

  • Like the other Snowflake policies, storage lifecycle policies are enabled with policies = true in the mode "snowflake" block.
  • Set archive_tier and archive_for_days together to archive the selected rows, or leave both out to expire them instead.
  • Snowflake cannot alter the arguments or the archive tier of a policy, so changing either recreates it.

New Schema Attributes

Atlas writes each attribute as the Snowflake parameter of the same name, and a contact block as WITH CONTACT:

AttributeValue
log_levelTRACE, DEBUG, INFO, WARN, ERROR, FATAL, or OFF
trace_levelALWAYS, ON_EVENT, or OFF
enable_data_compactiontrue or false
iceberg_default_ddl_collationA collation specification, such as "en-ci"
object_visibilityPRIVILEGED
classification_profileThe fully qualified name (database.schema.profile) of a classification profile
contactA repeatable block with a purpose (ACCESS_APPROVAL, SECURITY_COMPLIANCE, STEWARD, or SUPPORT) and the fully qualified name (database.schema.contact) of the contact
Note: In the declarative workflow, if a schema already sets one of these attributes outside Atlas, declare it in the desired state, or atlas schema apply plans to unset it.

Example

The env enables storage lifecycle policies with policies = true:

atlas.hcl
env "local" {  url = "snowflake://user:password@account_identifier/DEMO_DB?warehouse=DEMO_WH"  dev = "snowflake://user:password@account_identifier/DEMO_DEV_DB?warehouse=DEMO_WH"  schema {    src = "file://schema.hcl"    mode "snowflake" {      policies = true    }  }}

The desired schema declares a schema with the new attributes, and a policy that archives events older than a year in the COOL tier for 90 days:

schema.hcl
schema "PUBLIC" {}
schema "ANALYTICS" {  log_level                     = WARN  trace_level                   = ON_EVENT  enable_data_compaction        = false  iceberg_default_ddl_collation = "en-ci"  object_visibility             = PRIVILEGED  classification_profile        = "TR_ATLAS_GOVERNANCE.GOVERNANCE.PII_PROFILE"  contact {    purpose = SUPPORT    name    = "TR_ATLAS_GOVERNANCE.GOVERNANCE.SUPPORT_PORTAL"  }}
storage_lifecycle_policy "ARCHIVE_OLD_EVENTS" {  schema = schema.ANALYTICS  arg "EVENT_DATE" {    type = DATE  }  as               = "EVENT_DATE < CURRENT_DATE() - 365"  archive_tier     = COOL  archive_for_days = 90  comment          = "Archive events older than a year for 90 days"}

Run the diff:

atlas migrate diff --env local

Atlas writes the migration:

atlas migrate diff
-- Create "ANALYTICS" schemaCREATE SCHEMA "ANALYTICS" DATA_RETENTION_TIME_IN_DAYS = 1 LOG_LEVEL = 'WARN' TRACE_LEVEL = 'ON_EVENT' ENABLE_DATA_COMPACTION = FALSE ICEBERG_DEFAULT_DDL_COLLATION = 'en-ci' OBJECT_VISIBILITY = PRIVILEGED CLASSIFICATION_PROFILE = 'TR_ATLAS_GOVERNANCE.GOVERNANCE.PII_PROFILE' WITH CONTACT (SUPPORT = TR_ATLAS_GOVERNANCE.GOVERNANCE.SUPPORT_PORTAL);-- Create storage lifecycle policy "ARCHIVE_OLD_EVENTS"CREATE STORAGE LIFECYCLE POLICY "ANALYTICS"."ARCHIVE_OLD_EVENTS" AS ("EVENT_DATE" DATE) RETURNS BOOLEAN -> EVENT_DATE < CURRENT_DATE() - 365 ARCHIVE_TIER = COOL ARCHIVE_FOR_DAYS = 90 COMMENT = 'Archive events older than a year for 90 days';

Getting Started

Snowflake support is part of Atlas Pro. Run atlas login to get started.

See the Snowflake HCL reference for every attribute and block.

featuresnowflakestorage lifecycle policyschemaatlas pro