且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在python中使用Lambda触发器将用户迁移到Cognito

更新时间:2023-12-06 08:47:58

问题出在事件对象中,这就是我的目的已经更改为使其正常工作:
删除了行

The issue was in the event object, here's what I've changed to get this to work: removed the line

"desiredDeliveryMediums": "EMAIL",

因为这与参数- messageAction: SUPPRESS冲突。

because that's conflic with the parameter - "messageAction": "SUPPRESS".

"forceAliasCreation": "false" 

是不必要的,因为默认值为false。还应该进行测试以检查用户池中是否不存在用户名/电子邮件。

is not necessary, as false is the default value. There should also be a test to check if username/email don't already exist in the user pool.

我在用户池中使用以下代码进行了测试,它可以正常工作。

I tested with following code in my User Pool, it works.

def lambda_handler(event, context):
    ## print("migrateUserLambda Python")

    event["response"] = {
            "userAttributes": {
                "email": event["userName"],
                "email_verified": "true"
            },
            "finalUserStatus": "CONFIRMED",
            "messageAction": "SUPPRESS"
        }

    return event