Skip to content

fix(preview): reconcile preview lambda config on every push - #356

Open
nourshoreibah wants to merge 1 commit into
mainfrom
fix/preview-env-stale-config
Open

fix(preview): reconcile preview lambda config on every push#356
nourshoreibah wants to merge 1 commit into
mainfrom
fix/preview-env-stale-config

Conversation

@nourshoreibah

Copy link
Copy Markdown
Collaborator

A preview stack kept whatever environment it was born with. Both the step that resolves the env from prod and the terraform apply that delivers it were gated on create == 'true', so a labelled PR only ever redeployed lambda code on subsequent pushes -- the config was never revisited.

That went unnoticed until the RDS instance was given an explicit identifier. Its endpoint changed from terraform-20251009192006341800000001... to branch-rds..., prod picked the new value up on its next apply, and every preview stack created before that kept the old hostname. The old name no longer resolves, so all six preview lambdas threw

getaddrinfo ENOTFOUND terraform-20251009192006341800000001...

on any request that reached the database. Public routes still worked, which made it look like an auth bug: POST /auth/login and /auth/respond-challenge answered normally while GET /auth/me -- the first route to resolve a caller -- returned {"message":"Internal Server Error"} from dispatch's catch-all.

Both steps now run on every event. Terraform is declarative, so an apply where the resolved config already matches is an empty plan.

With the apply no longer conditional, the API URL comes from terraform output in both modes. That retires the fallback that looked the API up by name and told the reader to re-add the label when it was missing or had no stage -- the apply either repairs the stack or fails and stops the job. LABEL went with those two messages, its only consumers.

ℹ️ Issue

Closes

📝 Description

Write a short summary of what you added. Why is it important? Any member of C4C should be able to read this and understand your contribution -- not just your team members.

Briefly list the changes made to the code:

  1. Added support for this.
  2. And removed redunant use of that.
  3. Also this was included for reasons.

✔️ Verification

What steps did you take to verify your changes work? These should be clear enough for someone to be able to clone the branch and follow the steps themselves.

Provide screenshots of any new components, styling changes, or pages.

🏕️ (Optional) Future Work / Notes

Did you notice anything ugly during the course of this ticket? Any bugs, design challenges, or unexpected behavior? Write it down so we can clean it up in a future ticket!

A preview stack kept whatever environment it was born with. Both the step that
resolves the env from prod and the `terraform apply` that delivers it were gated
on `create == 'true'`, so a labelled PR only ever redeployed lambda *code* on
subsequent pushes -- the config was never revisited.

That went unnoticed until the RDS instance was given an explicit identifier. Its
endpoint changed from `terraform-20251009192006341800000001...` to
`branch-rds...`, prod picked the new value up on its next apply, and every
preview stack created before that kept the old hostname. The old name no longer
resolves, so all six preview lambdas threw

    getaddrinfo ENOTFOUND terraform-20251009192006341800000001...

on any request that reached the database. Public routes still worked, which made
it look like an auth bug: POST /auth/login and /auth/respond-challenge answered
normally while GET /auth/me -- the first route to resolve a caller -- returned
`{"message":"Internal Server Error"}` from dispatch's catch-all.

Both steps now run on every event. Terraform is declarative, so an apply where
the resolved config already matches is an empty plan.

With the apply no longer conditional, the API URL comes from `terraform output`
in both modes. That retires the fallback that looked the API up by name and told
the reader to re-add the label when it was missing or had no stage -- the apply
either repairs the stack or fails and stops the job. `LABEL` went with those two
messages, its only consumers.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@nourshoreibah nourshoreibah added the no-review The PR review bot won't run label Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-review The PR review bot won't run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant