Skip to content

Commit 6ffec56

Browse files
committed
Fix PostgreSQL secret ownership across recipes
Signed-off-by: willdavsmith <willdavsmith@gmail.com>
1 parent 400d66a commit 6ffec56

2 files changed

Lines changed: 18 additions & 19 deletions

File tree

Data/postgreSqlDatabases/recipes/kubernetes/terraform/main.tf

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ terraform {
1010

1111
variable "context" {
1212
description = "This variable contains Radius Recipe context."
13-
type = any
13+
type = any
1414
}
1515

1616
variable "memory" {
@@ -32,17 +32,17 @@ variable "memory" {
3232
}
3333

3434
locals {
35-
resource_name = var.context.resource.name
36-
application_name = var.context.application != null ? var.context.application.name : ""
37-
environment_name = var.context.environment != null ? var.context.environment.name : ""
38-
resource_group = element(split("/", var.context.resource.id), 5)
39-
namespace = var.context.runtime.kubernetes.namespace
40-
port = 5432
41-
tag = "16-alpine"
42-
username = var.context.resource.properties.username
43-
password = var.context.resource.properties.password
44-
database = try(var.context.resource.properties.database, "postgres_db")
45-
size_value = try(var.context.resource.properties.size, "S")
35+
resource_name = var.context.resource.name
36+
application_name = var.context.application != null ? var.context.application.name : ""
37+
environment_name = var.context.environment != null ? var.context.environment.name : ""
38+
resource_group = element(split("/", var.context.resource.id), 5)
39+
namespace = var.context.runtime.kubernetes.namespace
40+
port = 5432
41+
tag = "16-alpine"
42+
username = var.context.resource.properties.username
43+
password = var.context.resource.properties.password
44+
database = try(var.context.resource.properties.database, "postgres_db")
45+
size_value = try(var.context.resource.properties.size, "S")
4646

4747
labels = {
4848
"radapp.io/resource" = local.resource_name
@@ -150,6 +150,8 @@ resource "kubernetes_service" "postgres" {
150150
}
151151
}
152152

153+
# The administrator credentials are user-supplied Recipe inputs. They configure
154+
# PostgreSQL through the Kubernetes Secret above but are not Recipe outputs.
153155
output "result" {
154156
value = {
155157
resources = [
@@ -159,13 +161,8 @@ output "result" {
159161
]
160162
values = {
161163
host = "${kubernetes_service.postgres.metadata[0].name}.${kubernetes_service.postgres.metadata[0].namespace}.svc.cluster.local"
162-
port = local.port
164+
port = tostring(local.port)
163165
database = local.database
164166
}
165-
secrets = {
166-
password = local.password
167-
connectionString = "postgresql://${local.username}:${local.password}@${kubernetes_service.postgres.metadata[0].name}.${kubernetes_service.postgres.metadata[0].namespace}.svc.cluster.local:${local.port}/${local.database}"
168-
}
169167
}
170-
sensitive = true
171168
}

Data/postgreSqlDatabases/test/app.bicep

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ resource app 'Radius.Core/applications@2025-08-01-preview' = {
2020
// redacted on reads), whereas a container `env.value` is stored unencrypted on
2121
// the container resource and rendered literally into the Pod spec.
2222
resource dbCreds 'Radius.Security/secrets@2025-08-01-preview' = {
23-
name: 'postgresql-credentials'
23+
// Keep this distinct from the Recipe-owned `postgresql-credentials`
24+
// Kubernetes Secret that configures the PostgreSQL container.
25+
name: 'postgresql-client-credentials'
2426
properties: {
2527
environment: environment
2628
application: app.id

0 commit comments

Comments
 (0)