2023-03-24 19:48:53 +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"
|
|
|
|
tag = "active"
|
|
|
|
}
|
|
|
|
|
|
|
|
locals {
|
|
|
|
# Get Nomad address from Consul
|
|
|
|
nomad_node = data.consul_service.nomad.service[0]
|
|
|
|
nomad_node_address = "http://${local.nomad_node.node_address}:${local.nomad_node.port}"
|
|
|
|
|
|
|
|
# Get Vault address from Consul
|
|
|
|
vault_node = data.consul_service.vault.service[0]
|
|
|
|
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
|
|
|
|
token = var.vault_token
|
|
|
|
}
|
|
|
|
|
|
|
|
# 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"
|
|
|
|
# }
|
|
|
|
|
2022-08-23 16:50:55 +00:00
|
|
|
# Configure the Nomad provider
|
|
|
|
provider "nomad" {
|
2023-03-24 19:48:53 +00:00
|
|
|
address = length(var.nomad_address) == 0 ? local.nomad_node_address : var.nomad_address
|
2022-08-23 16:50:55 +00:00
|
|
|
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"
|
|
|
|
}
|