nomad_csi_volume

Creates and registers a CSI volume in Nomad.

This can be used to create and register CSI volumes in a Nomad cluster.

Example Usage

Creating a volume:

# It can sometimes be helpful to wait for a particular plugin to be available
data "nomad_plugin" "ebs" {
  plugin_id        = "aws-ebs0"
  wait_for_healthy = true
}

resource "nomad_csi_volume" "mysql_volume" {
  depends_on = [data.nomad_plugin.ebs]

  lifecycle {
    prevent_destroy = true
  }

  plugin_id    = "aws-ebs0"
  volume_id    = "mysql_volume"
  name         = "mysql_volume"
  capacity_min = "10GiB"
  capacity_max = "20GiB"

  capability {
    access_mode     = "single-node-writer"
    attachment_mode = "file-system"
  }

  mount_options {
    fs_type = "ext4"
  }

  topology_request {
    required {
      topology {
        segments = {
          rack = "R1"
          zone = "us-east-1a"
        }
      }

      topology {
        segments = {
          rack = "R2"
        }
      }
    }
  }
}

Argument Reference

The following arguments are supported:

Capability

Topology Request

Topology

In addition to the above arguments, the following attributes are exported and can be referenced:

Timeouts

nomad_csi_volume provides the following Timeouts configuration options.

Importing CSI Volumes

CSI volumes are imported using the pattern <volume ID>@<namespace> .

$ terraform import nomad_csi_volume.mysql mysql@my-namespace
nomad_csi_volume.mysql: Importing from ID "mysql@my-namespace"...
nomad_csi_volume.mysql: Import prepared!
  Prepared nomad_csi_volume for import
nomad_csi_volume.mysql: Refreshing state... [id=mysql@my-namespace]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.