[FEATURE REQUEST] - Command health check
devops-rob opened this issue · 0 comments
devops-rob commented
At the moment i have these two resources
resource "container" "postgres" {
network {
id = variable.psql_network.id
ip_address = variable.psql_network.ip_address
aliases = variable.psql_network.aliases
}
image {
name = "postgres:${variable.postgres_version}"
}
port {
local = variable.postgres_local_port
host = variable.postgres_host_port
remote = variable.postgres_remote_port
}
environment = {
POSTGRES_USER = variable.postgres_user
POSTGRES_PASSWORD = variable.postgres_password
}
volume {
source = "./directory/postgres/files/"
destination = "/files"
}
}
resource "remote_exec" "exec_container" {
target = resource.container.postgres.id
command = [
"sh",
"./files/psql-check.sh",
]
}
The second resource is pretty much a healthcheck to ensure that postgres is up, running, and ready to accept connections.
It would be great if we could use the inbuilt healthcheck instead but rather than a http healthcheck, it runs a command inside the container, or runs a script and you can define what code/codes are deemed to be healthy.
Below is a psuedo code example
health_check {
command = ["vault", "status"]
script = <<EOF
#!/bin/bash
EOF
exit_code = [0,255]
}
It would use either command, or script, not both. Script allows for inline bash to be written.