skills/tigrisdata/skills/tigris-lifecycle-management

tigris-lifecycle-management

SKILL.md

Tigris Lifecycle Management

Automate object expiration, storage tier transitions, and cleanup with lifecycle rules. Set policies that automatically delete temporary files, archive old data, and control storage costs.

Prerequisites

Before doing anything else, install the Tigris CLI if it's not already available:

tigris help || npm install -g @tigrisdata/cli

If you need to install it, tell the user: "I'm installing the Tigris CLI (@tigrisdata/cli) so we can work with Tigris object storage."

Quick Reference

Operation Command
Set rules tigris buckets lifecycle set <bucket> --config lifecycle.json
View rules tigris buckets lifecycle get <bucket>
Remove rules tigris buckets lifecycle delete <bucket>

Setting Lifecycle Rules

tigris buckets lifecycle set my-app-uploads --config lifecycle.json

Rule Format

{
  "Rules": [
    {
      "ID": "rule-name",
      "Filter": { "Prefix": "path/prefix/" },
      "Status": "Enabled",
      "Expiration": { "Days": 30 },
      "Transitions": [
        { "Days": 7, "StorageClass": "STANDARD_IA" },
        { "Days": 90, "StorageClass": "GLACIER" }
      ]
    }
  ]
}
Field Purpose
ID Human-readable rule name
Filter.Prefix Only apply to objects matching this prefix
Status "Enabled" or "Disabled"
Expiration.Days Delete objects after N days
Transitions Move objects between storage tiers

Common Patterns

Temporary Upload Cleanup

Delete files in tmp/ after 24 hours:

{
  "Rules": [
    {
      "ID": "cleanup-temp-uploads",
      "Filter": { "Prefix": "tmp/" },
      "Status": "Enabled",
      "Expiration": { "Days": 1 }
    }
  ]
}

Unverified Upload Expiration

Delete unprocessed uploads after 7 days:

{
  "Rules": [
    {
      "ID": "expire-unverified-uploads",
      "Filter": { "Prefix": "uploads/pending/" },
      "Status": "Enabled",
      "Expiration": { "Days": 7 }
    }
  ]
}

Session Data Cleanup

Auto-delete session files after 1 day:

{
  "Rules": [
    {
      "ID": "cleanup-sessions",
      "Filter": { "Prefix": "sessions/" },
      "Status": "Enabled",
      "Expiration": { "Days": 1 }
    }
  ]
}

Log Archival

Move logs to cheaper storage, then delete after 1 year:

{
  "Rules": [
    {
      "ID": "archive-logs",
      "Filter": { "Prefix": "logs/" },
      "Status": "Enabled",
      "Transitions": [
        { "Days": 30, "StorageClass": "STANDARD_IA" },
        { "Days": 90, "StorageClass": "GLACIER" }
      ],
      "Expiration": { "Days": 365 }
    }
  ]
}

Backup Retention

Keep backups for 30 days:

{
  "Rules": [
    {
      "ID": "expire-old-backups",
      "Filter": { "Prefix": "backups/" },
      "Status": "Enabled",
      "Expiration": { "Days": 30 }
    }
  ]
}

Old Asset Versions

Clean up old build artifacts:

{
  "Rules": [
    {
      "ID": "cleanup-old-builds",
      "Filter": { "Prefix": "builds/" },
      "Status": "Enabled",
      "Expiration": { "Days": 14 }
    }
  ]
}

Storage Tiers

Tier Cost Access Use For
STANDARD Highest Instant Frequently accessed files
STANDARD_IA Lower Instant, retrieval fee Infrequent access (>30 days old)
GLACIER Lowest Minutes-hours retrieval Archives, compliance (>90 days old)

When to Transition

Scenario Transition At Save
User uploads rarely re-accessed 30 days → IA ~40% storage cost
Compliance archives 90 days → Glacier ~80% storage cost
Build artifacts 7 days → IA, 30 days → delete ~90% with deletion

Multiple Rules Example

Combine rules for a complete lifecycle policy:

{
  "Rules": [
    {
      "ID": "cleanup-temp",
      "Filter": { "Prefix": "tmp/" },
      "Status": "Enabled",
      "Expiration": { "Days": 1 }
    },
    {
      "ID": "archive-uploads",
      "Filter": { "Prefix": "uploads/" },
      "Status": "Enabled",
      "Transitions": [
        { "Days": 90, "StorageClass": "STANDARD_IA" }
      ]
    },
    {
      "ID": "expire-backups",
      "Filter": { "Prefix": "backups/" },
      "Status": "Enabled",
      "Expiration": { "Days": 30 }
    },
    {
      "ID": "archive-logs",
      "Filter": { "Prefix": "logs/" },
      "Status": "Enabled",
      "Transitions": [
        { "Days": 30, "StorageClass": "STANDARD_IA" },
        { "Days": 90, "StorageClass": "GLACIER" }
      ],
      "Expiration": { "Days": 365 }
    }
  ]
}

Application-Level TTL

When lifecycle rules aren't granular enough (e.g., expiration based on metadata, not age), implement TTL in your application:

import { put, list, remove, head } from "@tigrisdata/storage";

// Store with expiration metadata
await put("tokens/abc123.json", data, {
  contentType: "application/json",
  // Store expiry as part of the key or track in your database
});

// Cleanup job: delete expired objects
async function cleanupExpired(prefix: string, maxAgeMs: number) {
  const result = await list({ prefix });
  const now = Date.now();

  for (const item of result.data?.items ?? []) {
    const age = now - new Date(item.modified).getTime();
    if (age > maxAgeMs) {
      await remove(item.path);
    }
  }
}

// Run daily
cleanupExpired("tokens/", 24 * 60 * 60 * 1000); // 24 hours

Interaction with Snapshots

  • Lifecycle rules apply to the source bucket, not snapshot copies
  • Objects deleted by lifecycle rules can be recovered from snapshots (if taken before deletion)
  • Consider snapshot frequency when setting expiration policies

Critical Rules

Always: Use lifecycle rules for predictable cleanup patterns | Set expiration on temporary/transient data | Use storage tier transitions for cost savings | Test rules on a non-production bucket first

Never: Rely solely on lifecycle for critical data deletion (add application-level checks) | Set short expiration on buckets with important data without backups | Forget that deleted objects are gone permanently (unless you have snapshots)


Related Skills

  • tigris-backup-export — Backup retention policies
  • tigris-egress-optimizer — Tier transitions for cost savings
  • tigris-snapshots-forking — Point-in-time recovery before deletion

Official Documentation

Weekly Installs
1
GitHub Stars
2
First Seen
7 days ago
Installed on
amp1
cline1
opencode1
cursor1
kimi-cli1
warp1