orchestration-tests/nomad/providers.tf

47 lines
1.3 KiB
Terraform
Raw Permalink Normal View History

2022-03-22 04:26:04 +00:00
# Configure Consul provider
provider "consul" {
address = var.consul_address
}
# Get Nomad client from Consul
data "consul_service" "nomad" {
name = "nomad-client"
}
# Get Vault client from Consul
data "consul_service" "vault" {
name = "vault"
2022-04-13 21:01:14 +00:00
tag = "active"
2022-03-22 04:26:04 +00:00
}
locals {
# Get Nomad address from Consul
2022-04-13 21:01:14 +00:00
nomad_node = data.consul_service.nomad.service[0]
2022-03-22 04:26:04 +00:00
nomad_node_address = "http://${local.nomad_node.node_address}:${local.nomad_node.port}"
# Get Vault address from Consul
2022-04-13 21:01:14 +00:00
vault_node = data.consul_service.vault.service[0]
2022-03-22 04:26:04 +00:00
vault_node_address = "http://${local.vault_node.node_address}:${local.vault_node.port}"
}
# Configure the Vault provider
provider "vault" {
address = length(var.vault_address) == 0 ? local.vault_node_address : var.vault_address
2022-04-13 21:01:14 +00:00
token = var.vault_token
2022-03-22 04:26:04 +00:00
}
# Something that should exist in a post bootstrap module, right now module includes bootstrapping
# which requries Admin
# data "vault_nomad_access_token" "deploy" {
# backend = "nomad"
# role = "deploy"
# }
# Configure the Nomad provider
provider "nomad" {
address = length(var.nomad_address) == 0 ? local.nomad_node_address : var.nomad_address
secret_id = var.nomad_secret_id
# secret_id = length(var.nomad_secret_id) == 0 ? data.vault_nomad_access_token.admin.secret_id : var.nomad_secret_id
region = "global"
}