Skip to content

fix(aws-sqs): precreate self-referential queue identity - #1356

Open
aryasaatvik wants to merge 3 commits into
alchemy-run:mainfrom
aryasaatvik:fix/sqs-self-referential-identity
Open

fix(aws-sqs): precreate self-referential queue identity#1356
aryasaatvik wants to merge 3 commits into
alchemy-run:mainfrom
aryasaatvik:fix/sqs-self-referential-identity

Conversation

@aryasaatvik

@aryasaatvik aryasaatvik commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Pre-create the stable SQS queue identity before reconciliation so queue policies can safely reference the queue's own ARN during a greenfield deploy.

Lifecycle

precreate  -> queue name / FIFO identity / ARN
reconcile  -> attributes, tags, and binding-contributed policy

The precreate phase creates or adopts only the physical shell, validates ownership and FIFO compatibility, and leaves mutable state to reconciliation. Existing foreign queues fail with a typed QueuePrecreateConflict; recently deleted queues retain bounded retry behavior.

Validation

  • ALCHEMY_TEST_DEV=1 mise exec bun@1.3.13 -- bun node_modules/alchemy-test/bin/alchemy-test.ts --sequential --test-name-pattern 'fresh create resolves a queue policy' test/AWS/SQS/Queue.test.ts
  • Result: 0 failed | 1 passed
  • ALCHEMY_TEST_DEV=1 mise exec bun@1.3.13 -- bun node_modules/alchemy-test/bin/alchemy-test.ts --sequential --test-name-pattern '^(?!.*QueueSink)' test/AWS/SQS/Queue.test.ts
  • Result: 0 failed | 15 passed
  • The complete file is 15 passed | 1 failed; the excluded existing QueueSink test has a virtual-entry resolution failure for alchemy/Runtime/Bootstrap/Lambda before the queue assertion runs. The same failure reproduces on origin/main, outside this diff.

Scope

This keeps queue identity creation separate from mutable reconciliation and does not change the existing queue attribute model.

Precreate the queue URL and ARN before resolving self-referential policies, and grant the bootstrap calls needed to discover that immutable identity.

Original-Commits: 210799615 8ae19a190

Upstream-Candidate: SQS precreated identity
}
// Return undefined to allow update function to be called for other attribute changes
}),
precreate: Effect.fn(function* ({ id, news = {}, session }) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we share any logic with create? Looks a bit redundant.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled the shared queue logic into helpers; precreate still only creates the shell. Pushed in 6c6d3f3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants