Skip to content

Cognito configuration ignored on redeploy when using existing User Pool #41

@amitkumawat-node

Description

@amitkumawat-node

Summary

On initial deployment, a new Cognito User Pool is created as expected when no environment variables are provided.

However, on subsequent deployments, even when explicitly providing:

  • USE_EXISTING_COGNITO=true
  • EXISTING_COGNITO_USER_POOL_ID=

the script overrides this configuration and creates a new Cognito User Pool instead of reusing the existing one.

Steps to Reproduce

  1. First deployment (no env variables):

    • Run deployment without USE_EXISTING_COGNITO
    • A new Cognito User Pool is created successfully
  2. Second deployment (reuse existing pool):

    • Set:
      export USE_EXISTING_COGNITO=true
      export EXISTING_COGNITO_USER_POOL_ID=
    • Run deployment again
  3. Observe behavior:

    • Script resets USE_EXISTING_COGNITO=false
    • A new Cognito User Pool is created again

Expected Behavior

When both variables are provided:

  • USE_EXISTING_COGNITO=true
  • EXISTING_COGNITO_USER_POOL_ID is valid

the script should:

  • Reuse the existing Cognito User Pool
  • Skip auto-detection and creation logic

Current Behavior

The script checks stack existence and overrides:

  • USE_EXISTING_COGNITO=false

even when the user has explicitly provided configuration.

Impact

  • Prevents reuse of existing Cognito resources
  • Leads to unnecessary creation of multiple User Pools
  • Breaks expected idempotent deployment behavior

Proposed Fix

Update logic to:

  • Respect user-provided configuration when both variables are set
  • Avoid overriding USE_EXISTING_COGNITO in that case
  • Only run auto-detection when configuration is not provided

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions