Hi, I want to create a lambda function which would...
# sst
m
Hi, I want to create a lambda function which would be called after user signs up via cognito. which means this function wouldn't be tied to any rest api. I couldn't find any example of creating a function using sst stack (or perhaps i missed). Can anyone point me to the document or help how to write this funciton.
c
We moved off of sst back to cdk so not sure if this will help, but this is how we did it in cdk:
Copy code
const PreSignupTrigger = new lambda.NodejsFunction(this, 'PreSignUpTrigger', {
      entry: 'tempNodeJSFunction/index.ts'                                              
    });

this.userPool = new cognito.UserPool(this, 'UserPool', {
      selfSignUpEnabled: true,
      removalPolicy: cdk.RemovalPolicy.DESTROY,                                         // TODO remove for production
      signInAliases: {
        email: true,
        username: false
      },
      autoVerify: {
        email: true
      },
      lambdaTriggers: {
        preSignUp: PreSignupTrigger
      }
    });
So for you just change the lambdaTriggers to
postConfirmation
m
@Chad (cysense) thanks. couple of follow up questions. 1. So my project is setup by sst and my lambdas exist in
src/lambda/*
. Should i be putting this lambda there too? 2. I am using SST cli to deploy to aws, for this cdk lambda, how would the deployment work?
c
I am not too sure about how to do it with SST, my understanding is that SST is an abstraction ontop of CDK so normal CDK patterns should work. 1. Yeah put your lambda in
src/lambda/*
and point
entry: src/lambda/YOURLMABDA'
at your lambda. 2. Should just be a normal SST deploy. You probably will not be able do local simulation as the lambda needs to receive events from cognito but a deploy should be fine.
j
@Chad (cysense) what was your main reason for abandoning SST? I realize this project is too bleeding edge for some use. Is there anything you discovered that was a major concern?
c
@Joe Kendal - We weren't 100% using SST but were in the process of migrating over form SAM + CDK when we decided to stop, so it wasn't really a big decision for us. The only reason we didn't migrate over to SST was that it actually didn't solve the problem we intended to use it for. We wanted to use SST for live lambda development, but getting it setup was more effort than it was worth. We are a security company, so the easy option of publicly exposing AWS resources was not an option for us. The second option of setting up a VPN, required waaay too much overhead to be a feasible and scalable solution for us long term. Overall I think SST is great, and we will likely be back in the future. We however decided to stick with the CDK, for the time being at least, because the extra benefits of SST didn't out weigh the maturity of CDK.