» Nomad Provider

HashiCorp Nomad is an application scheduler. The Nomad provider exposes resources to interact with a Nomad cluster.

Use the navigation to the left to read about the available resources.

» Example Usage

# Configure the Nomad provider
provider "nomad" {
  address = "http://nomad.mycompany.com:4646"
  region  = "us-east-2"
}

# Register a job
resource "nomad_job" "monitoring" {
  jobspec = file("${path.module}/jobspec.hcl")
}

» Argument Reference

The following arguments are supported:

  • address (string: "http://127.0.0.1:4646") - The HTTP(S) API address of the Nomad agent. This must include the leading protocol (e.g. https://). This can also be specified as the NOMAD_ADDR environment variable.

  • region (string: "") - The Nomad region to target. This can also be specified as the NOMAD_REGION environment variable.

  • ca_file (string: "") - A local file path to a PEM-encoded certificate authority used to verify the remote agent's certificate. This can also be specified as the NOMAD_CACERT environment variable.

  • cert_file (string: "") - A local file path to a PEM-encoded certificate provided to the remote agent. If this is specified, key_file is also required. This can also be specified as the NOMAD_CLIENT_CERT environment variable.

  • key_file (string: "") - A local file path to a PEM-encoded private key. This is required if cert_file is specified. This can also be specified via the NOMAD_CLIENT_KEY environment variable.

  • vault_token (string: "") - A vault token to be inserted in the job file. This can also be specified as the VAULT_TOKEN environment variable or using a vault token helper (see Vault's documentation for more details).

  • secret_id (string: "") - The Secret ID of an ACL token to make requests with, for ACL-enabled clusters. This can also be specified via the NOMAD_TOKEN environment variable.

» Multi-Region Deployments

Each instance of the nomad provider is associated with a single region. Use alias to specify multiple providers for multi-region clusters:

provider "nomad" {
  address = "http://nomad.mycompany.com:4646"
  region  = "us"
  alias   = "us"
}

provider "nomad" {
  address = "http://nomad.mycompany.com:4646"
  region  = "eu"
  alias   = "eu"
}

resource "nomad_job" "nomad_us" {
  provider = nomad.us
  jobspec  = file("${path.module}/jobspec-us.nomad")
}

resource "nomad_job" "nomad_eu" {
  provider = nomad.eu
  jobspec  = file("${path.module}/jobspec-eu.nomad")
}