I am trying to setup cognito which would use JWT a...
# sst
m
I am trying to setup cognito which would use JWT and i am getting error that
There is already a construct with name UserPool
Here is my code and detailed error response at the bottom.
Copy code
export default class MyStack extends sst.Stack {
  public readonly authorizer: apigAuthorizers.HttpUserPoolAuthorizer;

  constructor(scope: <http://sst.App|sst.App>, id: string, props?: sst.StackProps) {
    super(scope, id, props);

    //Setting up auth
    const userPool = new cognito.UserPool(this, 'UserPool', {
      selfSignUpEnabled: true,
      signInAliases: {email: true},
      signInCaseSensitive: false,
    });

    const userPoolclient = new cognito.UserPoolClient(this, 'UserPoolClient', {
      userPool: userPool,
      authFlows: {userPassword: true},
      idTokenValidity: Duration.days(1),
    });

    this.authorizer = new apigAuthorizers.HttpUserPoolAuthorizer({
      userPool: userPool,
      userPoolClient: userPoolclient,
    });
    //end up auth setup

    // Create a HTTP API
    const api = new sst.Api(this, "Api", {
      routes: {
        "GET /heartbeat": "src/lambda.heartbeat",
      },
    });

    // Show the endpoint in the output
    this.addOutputs({
      "ApiEndpoint": api.url,
      "UserPool": userPool.userPoolId,
      "UserPoolClient": userPoolclient.userPoolClientId,
    });
  }
and i am getting error
Copy code
Error: There is already a Construct with name 'UserPool' in MyStack [serverlessnotesapp-rest-api-ts-my-stack]
    at Node.addChild (/Users/username/prjs/rest-api-ts/node_modules/constructs/src/construct.ts:381:13)
    at new Node (/Users/username/prjs/rest-api-ts/node_modules/constructs/src/construct.ts:58:22)
    at new ConstructNode (/Users/username/prjs/rest-api-ts/node_modules/@aws-cdk/core/lib/construct-compat.ts:184:24)
    at Object.createNode (/Users/username/prjs/rest-api-ts/node_modules/@aws-cdk/core/lib/construct-compat.ts:55:11)
    at new Construct (/Users/username/prjs/rest-api-ts/node_modules/constructs/src/construct.ts:409:26)
    at new Construct (/Users/username/prjs/rest-api-ts/node_modules/@aws-cdk/core/lib/construct-compat.ts:52:5)
    at new CfnElement (/Users/username/prjs/rest-api-ts/node_modules/@aws-cdk/core/lib/cfn-element.ts:31:5)
    at new CfnOutput (/Users/username/prjs/rest-api-ts/node_modules/@aws-cdk/core/lib/cfn-output.ts:26:5)
    at /Users/username/prjs/rest-api-ts/node_modules/@serverless-stack/resources/src/Stack.ts:84:9
    at Array.forEach (<anonymous>)
t
The output you have needs a different name because it's conflicting with the name of the actual user pool
maybe try UserPoolOutput