Skip to content

fix: break circular CFN dependency in AuthStack - #4

Merged
ezekielelvis merged 1 commit into
mainfrom
fix/auth-stack-circular-dependency
Aug 2, 2026
Merged

ezekielelvis merged 1 commit into
mainfrom
fix/auth-stack-circular-dependency

Conversation

@ezekielelvis

Copy link
Copy Markdown
Contributor

Summary

  • The first deploy.yml run failed on EventTicketing-dev-Auth at changeset creation: Circular dependency between resources: [PostConfirmationTriggerB3C0710B, UserPoolWebClient4C9370B0, PostConfirmationTriggerServiceRoleDefaultPolicyFA0B8BFF, UserPoolORGANIZERGroupD373D8EB, UserPoolPostConfirmationCognito0E6001F8, UserPoolADMINGroupDA4BEA2B, PostConfirmationTriggerLogRetention846ACD84, UserPool6BA7E5F2, UserPoolUSERGroupAFC002D4]
  • Root cause: the post-confirmation Lambda's IAM policy referenced this.userPool.userPoolArn for its cognito-idp:AdminAddUserToGroup grant. Combined with addTrigger() wiring that same function into the pool's LambdaConfig, this forms Function -> Policy -> UserPool -> Function — CloudFormation rejects the cycle before creating anything.
  • Fix: scope the grant to arn:<partition>:cognito-idp:<region>:<account>:userpool/* instead of the pool's own ARN token, which drops the Policy -> UserPool edge. Only one user pool exists per stage, so this is pool-scoped in practice.

Verification

  • pnpm run typecheck, pnpm run lint, pnpm run synth all pass.
  • Inspected the synthesized EventTicketing-dev-Auth template: the policy document now only references AWS::AccountId (pseudo-parameter, no dependency edge) plus a literal wildcard — confirmed no Ref/Fn::GetAtt back to the UserPool resource remains in that statement.
  • Database, Notifications, Budget, and Frontend stacks already deployed successfully to eu-west-1 in the failed run and are unaffected; Auth (and downstream Api/Monitoring, which never got created) will deploy on the next deploy.yml run once this merges.

Test plan

  • Merge to main, let CI pass, confirm deploy.yml → deploy-infrastructure creates EventTicketing-dev-Auth successfully this time
  • Confirm deploy-frontend then runs and the site is reachable at the Frontend stack's CloudFront URL

🤖 Generated with Claude Code

…gger

The post-confirmation Lambda's IAM policy referenced this.userPool.userPoolArn
for the AdminAddUserToGroup grant, which combined with addTrigger() wiring the
same function into the pool's LambdaConfig, formed a cycle CloudFormation
rejected at changeset creation (Function -> Policy -> UserPool -> Function).
Scoping the grant to a wildcard userpool/* ARN in this account/region drops
the Policy -> UserPool edge and breaks the cycle; only one pool exists per
stage so it's pool-scoped in practice. Confirmed first deploy to eu-west-1:
Database/Notifications/Budget/Frontend created fine, Auth failed here.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi @ezekielelvis! 👋

Your private repo does not have access to Sourcery.

Please upgrade to continue using Sourcery ✨

@ezekielelvis
ezekielelvis merged commit c18a9cb into main Aug 2, 2026
2 checks passed
@ezekielelvis
ezekielelvis deleted the fix/auth-stack-circular-dependency branch August 2, 2026 11:50
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.

1 participant