Hello there I want to create default cognito users...
# help
b
Hello there I want to create default cognito users in a userpool after it is created. is sst support that? and is it a good practice to do that in
lib/Api.js
?
f
Hey @Bshr Ramadan, do you mean you wan to seed the user pool with a set of users? Can you elaborate on what you are trying to do a bit?
b
Yes, that is what I meant I want to make a userpool having users, so I don't create these users manually every deploy to a new stage @Frank
f
You can check out the
Script
construct. Ppl use it to do things like seeding the database. It should work well for seeding the user pool.
Here’s an example of configuring the
Script
to run after the deploy - https://docs.serverless-stack.com/constructs/Script#running-after-deploy
Let me know if that works for you
b
Thanks, I will try it
Hello @Frank when I run or deploy, the script is keeping in status
CREATE_IN_PROGRESS
I put the script in
lib/Api.js
constructor like so:
Copy code
const script = new sst.Script(this, 'CreateUsers', {
      function: 'scripts/createUsers/index.handler',
      params: {
        // params
        }
      },
    });
and the handler is something like this:
Copy code
exports.handler =  async (event, context) => {
    return Promise.all(users.map(async (user) => await createUser({
      // user fields
    })));
  }
and logs of the script's lambda function is empty. so did I miss something?
f
Hey @Bshr Ramadan, is the Script still stuck in
CREATE_IN_PROGRESS
?
Does it happen consistently on every deploy?
b
Hey @Frank Yes, it stills in that status, and every deploy, so the overall stack stay in
CREATE_IN_PROGRESS