42 lines
941 B
Terraform
42 lines
941 B
Terraform
|
resource "nomad_job" "mysql-server" {
|
||
|
jobspec = file("${path.module}/mysql.nomad")
|
||
|
|
||
|
# Block until deployed as there are servics dependent on this one
|
||
|
detach = false
|
||
|
}
|
||
|
|
||
|
resource "nomad_acl_policy" "secrets_mysql" {
|
||
|
name = "secrets-mysql"
|
||
|
description = "Give access to MySQL secrets"
|
||
|
rules_hcl = <<EOH
|
||
|
namespace "default" {
|
||
|
variables {
|
||
|
path "secrets/mysql" {
|
||
|
capabilities = ["read"]
|
||
|
}
|
||
|
path "secrets/mysql/*" {
|
||
|
capabilities = ["read"]
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
EOH
|
||
|
|
||
|
job_acl {
|
||
|
# job_id = resource.nomad_job.mysql-server.id
|
||
|
job_id = "mysql-server"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
# Create self-scoped psk so that config is valid at first start
|
||
|
resource "random_password" "mysql_mysql_psk" {
|
||
|
length = 32
|
||
|
override_special = "!@#%&*-_="
|
||
|
}
|
||
|
|
||
|
resource "nomad_variable" "mysql_mysql_psk" {
|
||
|
path = "secrets/mysql/allowed_psks/mysql"
|
||
|
items = {
|
||
|
psk = "mysql:${resource.random_password.mysql_mysql_psk.result}"
|
||
|
}
|
||
|
}
|