【问题标题】:How to set the trigger of a lambda function in amplify?如何在放大中设置 lambda 函数的触发器?
【发布时间】:2020-03-03 05:50:06
【问题描述】:

我正在使用 AWSamplify 框架在 Vue.js 中构建一个 web 应用程序。

目前,我正在使用 cognito 服务对用户进行身份验证。

我想在用户首次创建帐户时触发 lambda 函数。我已经使用以下命令创建了一个 lambda 函数:

amplify function add

我使用这个命令测试了我的功能:

amplify function invoke myLambdaFunction

现在我想在用户创建帐户时触发此功能。

知道我该怎么做吗?

谢谢, 亚历克西斯

【问题讨论】:

    标签: amazon-web-services aws-lambda amazon-cognito aws-amplify aws-amplify-cli


    【解决方案1】:

    我能够使用以下选项创建触发器:See Docs

    $ amplify auth update

    ? What do you want to do? Walkthrough all the auth configurations
    ? Select the authentication/authorization services that you want to use: User Sign-Up, Sign-In, connected with AWS IAM controls (Enables per-user Storage features fo
    r images or other content, Analytics, and more)
    ? Allow unauthenticated logins? (Provides scoped down permissions that you can control via AWS IAM) No
    ? Do you want to enable 3rd party authentication providers in your identity pool? No
    ? Do you want to add User Pool Groups? No
    ? Do you want to add an admin queries API? No
    ? Multifactor authentication (MFA) user login options: OPTIONAL (Individual users can use MFA)
    ? For user login, select the MFA types: SMS Text Message
    ? Please specify an SMS authentication message: Your authentication code is {####}
    ? Email based user registration/forgot password: Enabled (Requires per-user email entry at registration)
    ? Please specify an email verification subject: Your verification code
    ? Please specify an email verification message: Your verification code is {####}
    ? Do you want to override the default password policy for this User Pool? No
    ? Specify the app's refresh token expiration period (in days): 120
    ? Do you want to specify the user attributes this app can read and write? No
    ? Do you want to enable any of the following capabilities? 
    ? Do you want to use an OAuth flow? No
    ? Do you want to configure Lambda Triggers for Cognito? Yes
    ? Which triggers do you want to enable for Cognito 
    

    【讨论】:

      【解决方案2】:

      您可以使用 cli:

      % amplify auth update
      What do you want to do? Walkthrough all the auth configurations
      ...
      ? Do you want to configure Lambda Triggers for Cognito? Yes 
      ? Which triggers do you want to enable for Cognito Pre Sign-up
      ? What functionality do you want to use for Pre Sign-up
      Do you want to edit your custom function now? Yes
      

      然后你可以在这个新生成的函数中添加你的逻辑

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-01
      • 2021-12-29
      • 2021-04-12
      • 2021-05-24
      • 2015-10-13
      • 1970-01-01
      • 2019-04-07
      • 2018-03-08
      相关资源
      最近更新 更多