serverless.yml 如何在 Cognito Lambda Config 中引用 lambda 函数
serverless.yml How to reference lambda function in Cognito Lambda Config
我是无服务器的新手,我正在尝试从无服务器 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)
LambdaConfig:
DefineAuthChallenge: "arn:aws:lambda:${self:custom.region}:${self:custom.accountId}:function:t-challenge-define"
您需要按照上述格式添加特定格式的 arn。
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。
我是无服务器的新手,我正在尝试从无服务器 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)
LambdaConfig:
DefineAuthChallenge: "arn:aws:lambda:${self:custom.region}:${self:custom.accountId}:function:t-challenge-define"
您需要按照上述格式添加特定格式的 arn。
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。