A GitHub Action that manages Terraform state files using MongoDB as a backend. It automatically restores the latest tfstate snapshot before Terraform runs and saves the updated state after, keeping only the two most recent snapshots to prevent storage bloat. Version 1.2.3 is stable. Unlike S3 or Consul backends, this offers simple MongoDB-based state management directly in GitHub Actions workflows. It requires Node.js 24 and a MongoDB instance with read/write permissions.
npm install tfstate-loves-mongoNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Full workflow example showing checkout, mongo state management, and Terraform init/apply.
Store the MongoDB connection string in GitHub Actions secrets and reference it as ${{ secrets.MONGO_URI }}.Grant appropriate roles (e.g., readWrite) to the MongoDB user for the specified database.
If you need more history, you must back up the MongoDB collection externally.
Use a runner that supports Node.js 24 or specify 'runs-on: ubuntu-latest' which is compatible.
Ensure you are using the action via 'uses' in workflow, not as a package.
Verify the mongo-uri secret is correct and the MongoDB instance is reachable from GitHub Actions runners.
No action needed; it will create a snapshot after Terraform run.
No dependency data recorded yet.