# Snowflake Warehouse Missing Cost-Allocation Tags

> Flags Snowflake warehouses with none of the team, cost_center or environment tags, which leaves their credits unattributed.

Source: https://zop.dev/integrations/snowflake/recommendations/snowflake-warehouse-missing-cost-allocation-tags

---

## Credits you cannot attribute are credits nobody owns

Snowflake [object tags](https://docs.snowflake.com/en/user-guide/object-tagging/introduction) are schema-level objects you
assign to other objects as key and value pairs. Snowflake's own guidance is that tagging warehouses
lets you monitor resource usage and group it by cost center or another organizational unit.
Creating and setting tags is available on every edition.

Warehouses are the natural place to tag because they are where most compute credits are metered.
When one carries no allocation tags, its spend cannot be split by team or environment, and a
growing warehouse has no obvious owner to ask about it.

## Checking which warehouses have allocation tags

[TAG_REFERENCES](https://docs.snowflake.com/en/sql-reference/account-usage/tag_references) lists every tag assignment. This
returns warehouses with none of the three tags:

```sql
SHOW WAREHOUSES
  ->> SELECT w."name", w."size"
      FROM $1 w
      LEFT JOIN (
        SELECT DISTINCT object_name
        FROM SNOWFLAKE.ACCOUNT_USAGE.TAG_REFERENCES
        WHERE domain = 'WAREHOUSE'
          AND object_deleted IS NULL
          AND LOWER(tag_name) IN ('team', 'cost_center', 'environment')
      ) t ON t.object_name = w."name"
      WHERE t.object_name IS NULL;
```

The view can lag by up to 2 hours, shows only objects your role can access, and needs the
`GOVERNANCE_VIEWER` role. Snowflake's [cost attribution guide](https://docs.snowflake.com/en/user-guide/cost-attributing)
uses the same `domain = 'WAREHOUSE'` filter to join tags to warehouse metering.

## All three tags must be missing

ZopNight reads the warehouse's tag set and checks for a non-empty value under `team`,
`cost_center` and `environment`. It fires only when all three are absent. A warehouse with just one
of them, say `environment = 'prod'`, is treated as tagged and left alone.

## When a partly tagged warehouse passes

Because the gate is all-missing, partial tagging never produces a finding, and tags under other
names do not count. If the tag data cannot be read, it is treated as no tags. Tags on the databases
or tables a warehouse queries are not considered: the check is about the warehouse itself.

## No saving, but a gap in every cost report

This is a governance finding without a dollar figure. Tagging does not reduce spend; it makes
spend reviewable. The risk of leaving it is that the warehouse's credits stay in an unallocated line
that no team is accountable for.

## Tagging the warehouse

1. Create the tags once, in a governance schema, with CREATE TAG:
   `CREATE TAG IF NOT EXISTS governance.tags.team;` and the same for `cost_center` and `environment`.
2. Apply them to the warehouse:
   `ALTER WAREHOUSE etl_wh SET TAG governance.tags.team = 'data-eng', governance.tags.cost_center = 'cc-104', governance.tags.environment = 'prod';`
3. The role setting the tags needs either APPLY TAG on the account, or APPLY on each tag plus
   OWNERSHIP of the warehouse.
4. Add the tags to whatever creates new warehouses, so new ones arrive tagged.
