Terraform Provider for TrueNAS - Manage your NAS as code

Hi all,

I’ve recently published a Terraform provider for TrueNAS SCALE and Community editions. It allows you to manage your TrueNAS configuration using infrastructure-as-code principles.

Current features:

  • Datasets
  • Custom apps (non-catalog applications)
  • Files and host paths
  • Data sources for pools and datasets

The provider connects over SSH and uses midclt, so there’s no need for API keys - just a user with appropriate sudo permissions.

Links:

This is an early release, so I’d welcome any feedback or suggestions for additional resources to support.

Thanks!

1 Like

Terraform Provider for TrueNAS - Update (v0.4.0)

Hey everyone,

Wanted to share some updates on the Terraform provider for TrueNAS since the initial release. A lot has changed based on real-world usage and feedback.

Key improvements since v0.1.0:

:small_blue_diamond: App lifecycle control (v0.4.0)
You can now manage app state directly in Terraform with desired_state = "RUNNING" or "STOPPED". The provider waits for the app to reach a stable state before completing, with configurable timeouts.

:small_blue_diamond: Better error messages (v0.4.0)
When app deployments fail, you now see the actual Docker/compose logs inline instead of just “check /var/log/app_lifecycle.log”.

:small_blue_diamond: SSH session limits (v0.3.0)
Added max_sessions to prevent overwhelming TrueNAS with concurrent SSH connections during large terraform apply runs.

:small_blue_diamond: Host key verification (v0.2.0)
SSH connections now support host_key_fingerprint for security-conscious deployments.

:small_blue_diamond: Dataset improvements (v0.2.0)

  • full_path computed attribute gives you the actual mountpoint
  • force_destroy for cleaning up datasets with children
  • Direct permission management (mode/uid/gid) on dataset mountpoints

:small_blue_diamond: File resource (v0.2.0)
Ownership support and path traversal protection.

Install from Terraform Registry:

terraform {
  required_providers {
    truenas = {
      source  = "deevus/truenas"
      version = "~> 0.4.0"
    }
  }
}

Full changelog and docs available on GitHub: deevus/terraform-provider-truenas

Feedback and issues welcome!

Terraform Provider for TrueNAS - Update (v0.5.0 & v0.6.0)

Hey everyone,

Two new releases to share since the last update. These add some highly desired features for backups and data protection.

v0.6.0 - Cloud Sync Support

:small_blue_diamond: Cloud Sync Credentials
Store credentials for cloud storage providers directly in Terraform. Supports S3-compatible storage, Backblaze B2, Google Cloud Storage, and Azure Blob Storage with provider-specific attribute blocks. (Note: Only S3 has been tested against real TrueNAS so far - other providers are implemented based on the API spec but untested. Feedback welcome!)

resource "truenas_cloud_sync_credentials" "backblaze" {
  name = "backblaze-backup"
  
  b2 {
    account_id      = var.b2_account_id
    application_key = var.b2_app_key
  }
}

:small_blue_diamond: Cloud Sync Tasks
Define backup jobs as code with full control over scheduling, encryption, and transfer settings. Supports push/pull directions, bandwidth limits, and pre/post scripts.

resource "truenas_cloud_sync_task" "nightly_backup" {
  description   = "Nightly backup to B2"
  credentials   = truenas_cloud_sync_credentials.backblaze.id
  direction     = "PUSH"
  transfer_mode = "SYNC"
  path          = "/mnt/tank/important"
  
  schedule {
    minute = "0"
    hour   = "2"
    dom    = "*"
    month  = "*"
    dow    = "*"
  }
  
  encryption {
    enabled  = true
    password = var.encryption_password
  }
}

:small_blue_diamond: Cloud Sync Credentials Data Source
Look up existing credentials by name for use across configurations.

v0.5.0 - Snapshots & Cloning

:small_blue_diamond: Snapshot Resource
Create and manage ZFS snapshots with optional hold support to prevent accidental deletion.

resource "truenas_snapshot" "daily" {
  dataset = "tank/data"
  name    = "daily-2026-01-16"
  hold    = true
}

:small_blue_diamond: Snapshots Data Source
Query existing snapshots with filtering by dataset or name pattern.

:small_blue_diamond: Dataset Cloning
Create new datasets from snapshots using the snapshot_id attribute - useful for test environments or point-in-time copies.

resource "truenas_dataset" "test_clone" {
  pool        = "tank"
  path        = "test-data"
  snapshot_id = truenas_snapshot.daily.id
}

:small_blue_diamond: Version-Aware API Resolution
The provider now detects your TrueNAS version and adjusts API calls accordingly - better compatibility across SCALE releases.

:small_blue_diamond: Improved Error Reporting
Job failures now include relevant log excerpts directly in the Terraform output.

Install from Terraform Registry:

terraform {
  required_providers {
    truenas = {
      source  = "deevus/truenas"
      version = "~> 0.6.0"
    }
  }
}

Feedback and issues welcome!