Terraform module for managing volumes in the Hetzner Cloud.
It implements the following provider resources:
module "volume" {
  source  = "github.com/peterpramb/terraform-hcloud-volumes?ref=<release>"
  volumes = [
    {
      name       = "volume-nbg1-1"
      location   = "nbg1"
      size       = 10
      format     = "xfs"
      protection = true
      server     = {
        "name"      = "server-1"
        "id"        = "7569968"
        "automount" = true
      }
      labels     = {
        "managed"    = "true"
        "managed_by" = "Terraform"
      }
    }
  ]
}See examples for more usage details.
| Name | Version | 
|---|---|
| terraform | ≥ 0.13 | 
| Name | Version | 
|---|---|
| hcloud | ≥ 1.31 | 
| Name | Description | Type | Default | Required | 
|---|---|---|---|---|
| volumes | List of volume objects to be managed. | list(map(volume)) | See below | yes | 
| Name | Description | Type | Required | 
|---|---|---|---|
| name | Unique name of the volume. | string | yes | 
| location | Location of the volume. | string | yes | 
| size | Size of the volume (in GB). | number | yes | 
| format | Format volume after creation. | string | no | 
| protection | Protect volume from deletion. | bool | no | 
| server | Inputs for server attachment. | map(server) | no | 
| labels | Map of user-defined labels. | map(string) | no | 
| Name | Description | Type | Required | 
|---|---|---|---|
| name | Name of the server to attach the volume to. | string | yes | 
| id | ID of the server to attach the volume to. | string | yes | 
| automount | Automount the volume on attachment. | bool | no | 
volumes = [
  {
    name       = "volume-nbg1-1"
    location   = "nbg1"
    size       = 10
    format     = "xfs"
    protection = false
    server     = null
    labels     = {}
  }
]| Name | Description | 
|---|---|
| volumes | List of all volume objects. | 
| volume_ids | Map of all volume objects indexed by ID. | 
| volume_names | Map of all volume objects indexed by name. | 
| volume_attachments | List of all volume attachment objects. | 
| volume_attachment_ids | Map of all volume attachment objects indexed by ID. | 
| volume_attachment_names | Map of all volume attachment objects indexed by name. | 
volumes = [
  {
    "attachment" = {}
    "delete_protection" = false
    "format" = "xfs"
    "id" = "7285086"
    "linux_device" = "/dev/disk/by-id/scsi-0HC_Volume_7285086"
    "location" = "nbg1"
    "name" = "volume-nbg1-1"
    "size" = 10
  },
]
volume_ids = {
  "7285086" = {
    "attachment" = {}
    "delete_protection" = false
    "format" = "xfs"
    "id" = "7285086"
    "linux_device" = "/dev/disk/by-id/scsi-0HC_Volume_7285086"
    "location" = "nbg1"
    "name" = "volume-nbg1-1"
    "size" = 10
  }
}
volume_names = {
  "volume-nbg1-1" = {
    "attachment" = {}
    "delete_protection" = false
    "format" = "xfs"
    "id" = "7285086"
    "linux_device" = "/dev/disk/by-id/scsi-0HC_Volume_7285086"
    "location" = "nbg1"
    "name" = "volume-nbg1-1"
    "size" = 10
  }
}
volume_attachments = []
volume_attachment_ids = {}
volume_attachment_names = {}This module is released under the MIT License.