Skip to content

Terraform module for managing volumes in the Hetzner Cloud

License

Notifications You must be signed in to change notification settings

peterpramb/terraform-hcloud-volumes

Repository files navigation

License Latest Release Terraform Version

terraform-hcloud-volumes

Terraform module for managing volumes in the Hetzner Cloud.

It implements the following provider resources:

Usage

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.

Requirements

Name Version
terraform ≥ 0.13

Providers

Name Version
hcloud ≥ 1.31

Inputs

Name Description Type Default Required
volumes List of volume objects to be managed. list(map(volume)) See below yes

volume

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

server

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

Defaults

volumes = [
  {
    name       = "volume-nbg1-1"
    location   = "nbg1"
    size       = 10
    format     = "xfs"
    protection = false
    server     = null
    labels     = {}
  }
]

Outputs

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.

Defaults

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 = {}

License

This module is released under the MIT License.