Repository navigation
fix(modules): name per-app resources by app and inject usable Postgres credentials - #185
Merged
Merged
Conversation
…s credentials
S3, DynamoDB, SQS and RDS resources are now {team}-{app}-{name}, so two
apps in one team no longer collide. Postgres entries get a credential-free
postgresql:// URL (env), a JDBC URL (jdbc_env), the master user (user_env)
and the password as an ECS secret (password_env). The rds-db:connect grant
is dropped (IAM DB auth was never enabled). Generation rejects names that
would make an invalid RDS identifier, bucket or queue name.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Terraform Plan✅ No changes — infrastructure is up to date. Plan output |
This was referenced Oct 31, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
service-bucket,service-database,service-queueandservice-rdsnamed resources{team}-{name}, with no app name in it. Two apps in one team that both declare e.g.databases: [{name: main}]would collide.envgot the RDS endpoint ashost:port, which is not a usable connection URL. The master password went to SSM but was never injected into the task. The user was hardcoded topostgresand the app was never told what it was.rds-db:connect, but IAM database authentication is not enabled on the instance, so the grant did nothing.docs/app-yaml-reference.mddocumented the password at/{project}/apps/{name}/db-master-password. The real path is/javabin/apps/<team>/<dbname>/db-master-password.Change
Naming: the modules now name resources
{team}-{service}-{name}, whereserviceis the app name. That covers the S3 bucket (…-{account_id}), DynamoDB table, SQS queue and DLQ, and RDS (instance, subnet group, SG, final snapshot). The RDS password moves to/javabin/apps/{team}/{app}/{name}/db-master-password.service-rdsgets a new requiredservicevariable, and the generator passes it. The new names still match the boundary'sDenyBadName{team}-*patterns, the team exec role's/javabin/apps/{team}/*read, and the SSO deny onapps/*/*/db-master-password(IAM*spans/).app-secret-rolloutdoes not match the nested path, so it still ignores the password.Postgres wiring (generator): new keys
jdbc_env,user_envandpassword_env, next toenv,host_envandport_env.env→postgresql://host:port/db(libpq URI)jdbc_env→jdbc:postgresql://host:port/dbuser_env→ master userpassword_env→ the SSM password ARN as an ECSsecretsentryThe URLs contain no credentials, because the generated password has characters that would need URL-encoding. New module outputs:
url,jdbc_url,username.master_usernameis now a variable (defaultpostgres).IAM: the
rds-db:connectstatement is gone. The task role keepsssm:GetParameteron its own password.Adopted DBs:
env,jdbc_env,user_envandpassword_envare rejected withadopt. The platform does not know the database name or credentials of an adopted DB, so those values stay insecrets:.host_envandport_envwork as before.Validation: generation now rejects names that would make an invalid resource:
It also rejects one variable name used for two database values, and a database variable that another resource already sets.
Docs:
docs/app-yaml-reference.md(env table, correct password path, naming table),docs/reusable-modules.md,terraform/modules/README.mdandCLAUDE.md.Existing resources: nothing is renamed
On 2026-10-31 I checked live AWS (
AWS_PROFILE=javabin, account 553637109631) and every app state injavabin-terraform-state-553637109631: cupcake/cupcake-backend, cupcake/cupcake, javazoneweb/javazone-2027, jzwatch/jz-watch and testteam/platform-test-app. None of them contains abucket_*,database_*,queue_*orrds_*module. Onlysecret_*modules exist, and their naming does not change.dbmoresleep, is a legacy instance meant foradopt, and the adopted path does not change.javazone-talk-events, comes from a separate project (Project=javazone-es-integration), not from this module.buckets/databases/queuesin javaBinapp.yamlfiles finds only commented examples inapp-template.So no compat or
movedpath is needed. If an app adds one of these resources before this merges, its next plan would replace that resource. Check new app PRs for that until this lands.Verification
python3 -m unittest discover -s scripts/tests: 142 tests OK. NewPerAppResourceTestcovers app naming in every module, URL/JDBC/user/password injection (password insecrets, notenvironment), variable-name clashes, and the identifier, bucket and queue name limits. The adopt tests cover the rejected keys.python3 -m unittest discover -s terraform/lambda-src/tests: 219 tests OK.terraform fmt -check -recursive terraform/modules, andterraform validateforservice-rds,service-bucket,service-databaseandservice-queue.terraform init -backend=false && terraform validate: valid.🤖 Generated with Claude Code