fix(aws): destroy converges in one pass with VPC-attached Lambdas - #937
Merged
Merged
Conversation
Deleting a VPC-attached Lambda leaves Hyperplane ENIs in its subnets and security group: they detach ~4 min after DeleteFunction, and AWS's own reaper can take 20+ min to delete them. Subnet (~12 min) and SecurityGroup (~2.5 min) DependencyViolation retry budgets expired first, failing destroy and forcing users to run it multiple times. - EC2/LingeringEnis: retryWhileLingeringEnis wraps Subnet/SecurityGroup deletes — on DependencyViolation it deletes detached Lambda ENIs explicitly (detached ENIs flip InterfaceType lambda->interface, so match by description like Terraform) and extends the budget to ~25 min only while the blockers are Lambda ENIs. - Lambda/Function: precreate no longer forwards news.vpc into CreateFunction — precreate props are unresolved, so Output-valued subnet ids crashed serialization; reconcile attaches the resolved VPC config. - test: live regression (FAST-gated) proving one destroy removes the whole Network + SG + VPC Lambda stack. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Install the packages built from this commit: alchemy bun add alchemy@https://pkg.ing/alchemy/2c75115@alchemy.run/better-auth bun add @alchemy.run/better-auth@https://pkg.ing/@alchemy.run/better-auth/2c75115@alchemy.run/pr-package bun add @alchemy.run/pr-package@https://pkg.ing/@alchemy.run/pr-package/2c75115 |
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.
Fixes the destroy failure reported with https://github.com/xofromthemoon/alchemy-aws-demo — destroying a stack with a VPC-attached Lambda failed with subnets/security groups stuck on
DependencyViolation(Waiting for dependencies to clear... (attempt 17)), forcing users to rundestroymultiple times.Root cause:
DeleteFunctionreturns immediately, but the function's Hyperplane ENIs stayin-usein their subnets/security group for minutes and AWS's own reaper can take 20+ minutes to delete them after they detach (reproduced live: ENIs detached ~4 min after function delete and were still undeleted 12+ min later). The Subnet retry budget (~12 min) and SecurityGroup budget (~2.5 min) both expired first, failing the destroy even though deletion ordering was correct.EC2/LingeringEnis.ts: sharedretryWhileLingeringEnis— on everyDependencyViolation, observe the ENIs still occupying the subnet/SG and explicitly delete detached Lambda ENIs instead of waiting for Lambda's reaper. While the blockers are Lambda ENIs (guaranteed to clear), the retry budget extends from ~12 min to ~25 min; other dependencies keep the base budget.EC2/Subnet.ts,EC2/SecurityGroup.ts: delete paths now retry through the reaper (SecurityGroup's budget was previously only 30×5s).Lambda/Function.ts:precreateno longer forwardsnews.vpcintoCreateFunction— precreate props are unresolved, so an Output-valued subnet id crashed serialization (ParseError: Expected string, got PrivateSubnet1.subnetId). The stub is created without a VPC config;reconcileattaches the resolved config as before.test/AWS/Lambda/VpcFunctionDestroy.test.ts: live regression test (FAST-gated) — deploys Network + SG + VPC-attached function, asserts onedestroyremoves everything including the VPC. Failed before the fix with the exact symptoms from the report; passes in a single pass with it.