Rasikh Mashhadi
Rasikh Mashhadi

Reputation: 1472

serverless.yml How to reference lambda function in Cognito Lambda Config

I am pretty new to serverless and I am trying to setup custom challenge for Cognito from serverless yaml file. I have following function

functions: t-challenge-define: handler: t-auth-challenge.define t-challenge-create: handler: t-auth-challenge.create t-challenge-response: handler: t-auth-challenge.verifyResponse resources: Resources: CognitoUserPool: Type: AWS::Cognito::UserPool Properties: UserPoolName: my_user_pool_name MfaConfiguration: "OFF" UsernameAttributes: - phone_number Schema: - Name: phone_number AttributeDataType: String Mutable: false Required: true - Name: locale AttributeDataType: String Mutable: true Required: true LambdaConfig: DefineAuthChallenge: (how do i reference func here)

Upvotes: 2

Views: 2371

Answers (2)

dennypc
dennypc

Reputation: 161

LambdaConfig:
      DefineAuthChallenge:
        Fn::GetAtt: [ T-challenge-defineLambdaFunction, Arn ]
      CreateAuthChallenge:
        Fn::GetAtt: [ T-challenge-createLambdaFunction, Arn ]
      VerifyAuthChallengeResponse:
        Fn::GetAtt: [ T-challenge-responseLambdaFunction, Arn ]

You can also leverage the GetAtt CloudFormation function to get the exact ARN for your lambda functions.

Upvotes: 5

Muhammad Shoaib
Muhammad Shoaib

Reputation: 745

LambdaConfig:
 DefineAuthChallenge: "arn:aws:lambda:${self:custom.region}:${self:custom.accountId}:function:t-challenge-define"

you need to add arn with specific format as above.

Upvotes: 3

Related Questions