【发布时间】:2017-10-24 03:08:31
【问题描述】:
使用 .Net Core 1.0 Lambda 我希望能够创建一个 Lambda 函数来处理来自 AWS Cognito 用户池的 PreSignUp 触发器。
using Amazon.Lambda.Core;
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
public class PreSignUp_SignUp
{
public string userPoolId { get; set; }
public const string EmailKey = "email";
public const string PhoneNumber = "phone_number";
public Dictionary<string,string> userAttributes { get; set; }
public Dictionary<string, string> validationData { get; set; }
}
public class PreSignup_SignUpResponse
{
public bool autoConfirmUser { get; set; }
}
public class Function
{
public PreSignup_SignUpResponse FunctionHandler(PreSignUp_SignUp input, ILambdaContext context)
{
return new PreSignup_SignUpResponse { autoConfirmUser = true };
}
}
虽然请求成功并在调用 Lambda 时返回响应,但示例请求如下:
{
"datasetName": "datasetName",
"eventType": "SyncTrigger",
"region": "us-east-1",
"identityId": "identityId",
"datasetRecords": {
"SampleKey2": {
"newValue": "newValue2",
"oldValue": "oldValue2",
"op": "replace"
},
"SampleKey1": {
"newValue": "newValue1",
"oldValue": "oldValue1",
"op": "replace"
}
},
"identityPoolId": "identityPoolId",
"version": 2
}
通过 .Net AmazonCognitoIdentityProviderClient 执行实际注册时,我收到错误消息:
Amazon.CognitoIdentityProvider.Model.InvalidLambdaResponseException : 无法识别的 lambda 输出
我猜这意味着我没有得到正确的响应(甚至可能是请求)的形状。
是否有人提供适用于 AWS Cognito 中 PreSignUp 触发器的 .Net Lambda 函数示例?
【问题讨论】:
标签: c# amazon-web-services .net-core aws-lambda aws-cognito