Add drift detection to reconcile stored state against live cloud resources
Opened by swampadmin · 6/10/2025
Problem
After performing operations (create, delete, update), there is no way to verify whether the stored data in swamp matches the actual state of resources in the cloud provider. This creates several problems:
After deletion
When a resource is deleted via swamp model method run web-droplet delete, the stored data persists. There's no indication that the resource no longer exists. The user has to either check the cloud console or run get on each resource and look for 404 errors to confirm cleanup.
After external changes
If someone modifies infrastructure outside of swamp (via the cloud console, another tool, or API), swamp's stored state becomes silently stale. There's no way to discover this drift.
After provisioning
Resources like load balancers transition through states (new → active) after creation. The stored data reflects the creation-time snapshot, not the current state. There's no "refresh all" to update everything at once.
Real-world scenario
After tearing down dev infrastructure (5 resources), confirming everything was actually deleted required:
swamp model method run web-firewall get --input '...' --json # hope for 404
swamp model method run web-lb get --input '...' --json # hope for 404
swamp model method run web-droplet get --input '...' --json # hope for 404
swamp model method run web-droplet get --input '...' --json # second droplet
swamp model method run web-vpc get --input '...' --json # hope for 404And each of these requires providing all model inputs (see related issue about model inputs validation on all methods), making it even more tedious.
Proposed solution
swamp status or swamp drift command
A command that compares stored data against live API state:
swamp status --jsonOutput:
web-vpc stored: 379edfed live: active ✓ in sync
web-droplet/web-1 stored: 556223958 live: active ✓ in sync
web-droplet/web-2 stored: 556223959 live: not found ✗ deleted externally
web-lb stored: d8624a18 live: active ⚠ ip changed (pending → 143.198.1.1)
web-firewall stored: 883d89d4 live: active ✓ in syncThis would:
- Iterate over all models with stored data
- Call
geton each using the stored resource ID - Compare stored attributes against live response
- Report differences (deleted, modified, in-sync)
swamp sync command
Optionally, a command to refresh all stored data to match live state:
swamp sync --json # refresh all
swamp sync web-lb --json # refresh specific modelSummary
Changes would be needed in:
- New CLI command(s) (
status/drift/sync) - Data service — ability to enumerate all stored data across models
- Method execution — batch
getcalls using stored resource IDs - Output rendering — diff view comparing stored vs live attributes
- Models would need a convention for which method refreshes state (typically
get) and which stored field is the resource ID (typicallyid)
Closed
No activity in this phase yet.
Sign in to post a ripple.