Skip to content

Commit 6268797

Browse files
labkey-willmclaude
andcommitted
Seed postgres with SSM DB credentials for local dev with SSM mode
When LABKEY_SSM_PREFIX is set, fetch database_user and database_password from SSM at make time and export them as POSTGRES_USER/POSTGRES_PASSWORD so the postgres container initializes with the same credentials that LabKey will fetch from SSM at runtime. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
1 parent dbb4407 commit 6268797

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ LABKEY_VERSION ?= 21.5-SNAPSHOT
3030
LABKEY_DISTRIBUTION ?= community
3131
LABKEY_EK ?= 123abc456
3232

33+
# When running with SSM credentials, seed postgres with the same DB user/password
34+
# that LabKey will fetch from SSM — otherwise the pg container initializes with
35+
# its defaults (postgres/localdevpassword) and auth fails.
36+
ifdef LABKEY_SSM_PREFIX
37+
_SSM_NORMED := $(shell echo '$(LABKEY_SSM_PREFIX)' | sed 's:/*$$:/:')
38+
_SSM_DB_USER := $(shell aws ssm get-parameter --name '$(_SSM_NORMED)database_user' --with-decryption --query 'Parameter.Value' --output text 2>/dev/null)
39+
_SSM_DB_PASS := $(shell aws ssm get-parameter --name '$(_SSM_NORMED)database_password' --with-decryption --query 'Parameter.Value' --output text 2>/dev/null)
40+
ifneq ($(_SSM_DB_USER),)
41+
POSTGRES_USER ?= $(_SSM_DB_USER)
42+
endif
43+
ifneq ($(_SSM_DB_PASS),)
44+
POSTGRES_PASSWORD ?= $(_SSM_DB_PASS)
45+
endif
46+
endif
47+
3348
LOG4J_CONFIG_OVERRIDE ?= default.log4j2.xml
3449

3550
BUILD_ARCHITECTURE ?= linux/amd64

0 commit comments

Comments
 (0)