Muhammad Ali
11/01/2021, 8:26 PMThere is already a construct with name UserPool
Here is my code and detailed error response at the bottom.
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
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>)
thdxr
11/01/2021, 8:28 PMthdxr
11/01/2021, 8:28 PM