Giter Club home page Giter Club logo

Comments (8)

jayair avatar jayair commented on August 12, 2024

Can you tell me more about this?

not working for imported lambda from another file

from ion.

imdkbj avatar imdkbj commented on August 12, 2024

Hi @jayair Please find. Am i doing something wrong!

Screenshot 2024-07-22 at 12 01 09 AM
import { config } from 'dotenv'

const _stage = $app.stage
const parsedENV = config({ path: `./lambda/.env.${_stage}` }).parsed

export const lambda = new sst.aws.Function('CognitoHandler', {
  handler: './lambda/index.handler',
  environment: {
    ...parsedENV,
    MAX_ATTEMPTS: 3
  },
  description: 'cognito-handlers',
  runtime: 'nodejs20.x',
  timeout: '10 seconds',
  memory: '1024 MB',
  permissions: [
    {
      actions: ['ses:SendEmail', 'ses:SendRawEmail'],
      resources: ['*']
    },
    {
      actions: ['sns:Publish', 'sns:Subscribe'],
      resources: ['*']
    }
  ],
  logging: {
    retention: '3 year' // for audit purpose
  },
  transform: {
    function: {
      name: `${_stage}-sso-cognito-handler`
    }
  }
})

from ion.

fwang avatar fwang commented on August 12, 2024

@imdkbj When you pass in function ARNs via transform, you are responsible for creating the function and assigning the required permissions. So you'd have to create the aws.lambda.Permission resources as shown in ur code block above.

Btw, why r the functions created separately? Can't you create them inline?

from ion.

imdkbj avatar imdkbj commented on August 12, 2024

Hey @fwang Thanks for the inputs.

  1. Agree with the transform point.
  2. I am creating seprate lamda as only one lambda is being assigned to all event. Lambda is being created in same sst deploy session not isolated anyhow.
  3. Can you check why last photo why that is giving promise error. That can solver the underlying permission issue.

If required, I can share the all codes here.

from ion.

fwang avatar fwang commented on August 12, 2024

@imdkbj triggers expects path to the function handler, not ARN of existing functions.

Give this a try:

new sst.aws.CognitoUserPool("MyUserPool", {
  transform: {
    userPool: {
      lambdaConfig: {
        createAuthChallenge: lambda.arn,
        defineAuthChallenge: lambda.arn,
        ...
      }
    }
  }
});

Feel free to reopen this if issue persist.

from ion.

imdkbj avatar imdkbj commented on August 12, 2024

Hi @fwang Thanks.
As you can see in my screenshot, I am using the exactly same. But how we can make use without transformer where a single lambda will be used for multiple triggers as if we use path then multiple lambda will be created.

from ion.

jayair avatar jayair commented on August 12, 2024

I'm confused, are you saying you don't want to use the transform?

from ion.

imdkbj avatar imdkbj commented on August 12, 2024

Hey, Yes! I can skip transform if we can get the option to pass path/arn to the function handler.

from ion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.