serverless.yml如何在Cognito Lambda Config中引用lambda函数

时间:2018-06-01 03:40:31

标签: amazon-web-services aws-lambda serverless cognito

我是无服务器的新手,我正在尝试从无服务器的yaml文件设置Cognito的自定义挑战。我有以下功能

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)

2 个答案:

答案 0 :(得分:3)

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

您需要添加具有上述特定格式的arn。

答案 1 :(得分:2)

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

您还可以利用GetAtt CloudFormation函数来获取lambda函数的确切ARN。