fix(aws/ec2): harden SecurityGroup reconcile + add lifecycle convergence tests#222
Open
sam-goodwin wants to merge 1 commit intomainfrom
Open
fix(aws/ec2): harden SecurityGroup reconcile + add lifecycle convergence tests#222sam-goodwin wants to merge 1 commit intomainfrom
sam-goodwin wants to merge 1 commit intomainfrom
Conversation
…nce tests
- Wrap describeSecurityGroups in a bounded eventual-consistency retry that rides out InvalidGroup.NotFound and the SG-not-yet-visible window immediately after createSecurityGroup. Both the post-create lookup and the final re-read now use the same helper.
- Replace the full-revoke/full-reauthorize rule sync with a canonical-key diff (protocol + port range + source + description), so reconcile only applies the delta. AWS deduplicates identical rule shapes, so this canonicalization is what AWS uses internally.
- read now searches by alchemy tag filters when state lacks a groupId, treats a vanished SG as undefined (so reconcile recreates it), and returns Unowned(attrs) for foreign-tagged SGs to gate adoption behind adopt(true).
- delete previously matched DependencyViolation by both its proper tag AND a brittle e._tag === "ValidationError" && e.message?.includes("DependencyViolation") substring check. Distilled tags DependencyViolation directly via withDependencyViolationError, so the substring branch is dead code that swallowed unrelated ValidationErrors. Drop it.
- Add lifecycle convergence tests: idempotent redeploy, drift convergence after out-of-band ingress/egress mutation, recreate after out-of-band deletion (rides eventual-consistency), replace on groupName change, rule-set diff on add/remove/change, double-destroy idempotency, foreign-tag takeover via adopt(true).
.worktrees/ joins .gitignore (matching the VPC hardening PR) so per-resource hardening worktrees stay untracked.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
|
Install the packages built from this commit: alchemy bun add alchemy@https://pkg.ing/alchemy/df3833b@alchemy.run/better-auth bun add @alchemy.run/better-auth@https://pkg.ing/@alchemy.run/better-auth/df3833b@alchemy.run/pr-package bun add @alchemy.run/pr-package@https://pkg.ing/@alchemy.run/pr-package/df3833b |
Contributor
Website Preview DeployedURL: https://alchemyeffectwebsite-worker-pr-222-eeeczzzx4ipb72uw.testing-2b2.workers.dev Built from commit This comment updates automatically with each push. |
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.
Harden the EC2
SecurityGroupreconciler against eventual-consistency races and rule drift, then add lifecycle convergence tests on top ofScratchStack.Reconciler changes
Rule sync used to revoke every observed rule and re-authorize the desired set every reconcile. Replaced with a canonical-key diff (protocol + ports + source + description) so we only apply the delta:
readnow searches by alchemy tag filters when state is missing, returnsUnowned(attrs)for foreign-tagged SGs (gating adoption behindadopt(true)), and treats a vanished SG asundefinedso the engine recreates it.deletepreviously also matchede._tag === "ValidationError" && e.message?.includes("DependencyViolation"). That branch was dead — distilled tagsDependencyViolationdirectly viawithDependencyViolationError, so the substring match never fired and any realValidationErrorwas being swallowed silently. Drop it.New lifecycle tests
groupNametriggers replace; old SG is deletedadopt(true)to take overDistilled patch
No patch needed — error categorization for SG flows (
InvalidGroup.NotFound,InvalidPermission.NotFound,DependencyViolation) is already correct in distilled..worktrees/joins.gitignore(matching the VPC hardening PR) so per-resource hardening worktrees stay untracked.