Skip to content

Commit 24bda2c

Browse files
committed
[BOYSCOUT]: Generate and wire status check token
Generate a per-deployment status check token and inject it into the rendered deployment CR so the server /livez and /readyz probes can validate it. - Add a random_password resource that produces a 32-char alphanumeric token by default. - Resolve the token via coalesce(var.status_check_token, generated), changing the variable default from "token" to null so the generated value is used unless an operator overrides it explicitly. - Pass the resolved token into the infra_settings.tpl templatefile call and render it as global.statusCheckToken (quoted for YAML safety). - Declare the hashicorp/random provider in versions.tf.
1 parent 477a8d1 commit 24bda2c

4 files changed

Lines changed: 20 additions & 2 deletions

File tree

examples/deployment/infra/config.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# Generate a random status check token by default. It is used by the server
2+
# /livez and /readyz probes. Operators can override it by setting the
3+
# status_check_token variable explicitly.
4+
resource "random_password" "status_check_token" {
5+
length = 32
6+
special = false
7+
}
8+
9+
locals {
10+
status_check_token = coalesce(var.status_check_token, random_password.status_check_token.result)
11+
}
12+
113
# Output the infrastructure configuration to console
214
output "infra_config" {
315
description = "Infrastructure configuration for Datafold deployment"
@@ -32,6 +44,7 @@ output "infra_config" {
3244
redis_data_volume_id = module.aws[0].redis_data_volume_id,
3345
server_name = module.aws[0].domain_name,
3446
vpc_cidr = module.aws[0].vpc_cidr,
47+
status_check_token = local.status_check_token,
3548

3649
# service accounts vars
3750
dfshell_role_arn = module.aws[0].dfshell_role_arn,

examples/deployment/infra/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ variable "backend_app_port" {
66

77
variable "status_check_token" {
88
type = string
9-
default = "token"
10-
description = "The status check token to apply"
9+
default = null
10+
description = "The status check token used by the server /livez and /readyz probes. When left unset (null), a random token is generated automatically."
1111
}

examples/deployment/infra/versions.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@ terraform {
44
source = "carlpett/sops"
55
version = "~> 0.5"
66
}
7+
random = {
8+
source = "hashicorp/random"
9+
version = "~> 3.0"
10+
}
711
}
812
}

examples/deployment/templates/infra_settings.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ global:
3232
server: ${postgres_server}
3333
serverName: ${server_name}
3434
vpcCidr: ${vpc_cidr}
35+
statusCheckToken: "${status_check_token}"
3536

3637
nginx:
3738
service:

0 commit comments

Comments
 (0)