github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/demo/csi/digitalocean/main.tf (about) 1 # Terraform configuration for creating a volume in DigitalOcean and 2 # registering it with Nomad 3 4 # create the volume 5 resource "digitalocean_volume" "test_volume" { 6 region = var.region 7 name = "csi-test-volume" 8 size = 50 9 initial_filesystem_type = "ext4" 10 description = "a volume for testing Nomad CSI" 11 } 12 13 # run the plugin job 14 resource "nomad_job" "plugin" { 15 jobspec = templatefile("${path.module}/plugin.nomad", { token = var.do_token }) 16 } 17 18 # register the volume with Nomad 19 resource "nomad_volume" "test_volume" { 20 volume_id = var.volume_id 21 name = var.volume_id 22 type = "csi" 23 plugin_id = "digitalocean" 24 external_id = digitalocean_volume.test_volume.id 25 access_mode = "single-node-writer" 26 attachment_mode = "block-device" 27 deregister_on_destroy = true 28 } 29 30 # consume the volume 31 resource "nomad_job" "redis" { 32 jobspec = templatefile("${path.module}/volume-job.nomad", { volume_id = nomad_volume.test_volume.id }) 33 depends_on = [nomad_volume.test_volume] 34 }