找到你要的答案

Q:Triggering a AWS Lambda from a form post

Q:触发从形式发布AWSλ

I've created a small AWS Lambda that sends an email using SES. I'm looking to hookup a contact us form from a static website to this lambda.

Is it possible to have the contact us form post directly to a url of the lambda? I'm not using a server side framework and would really like to avoid it, what are my options? Is there client side Javascript way to invoke the lambda?

我创建了一个小的AWSλ,发送电子邮件使用SES。我想勾搭一个联系的形式从静态网站这λ。

可能有联系的形式直接发布网址的λ?我不使用服务器端框架,真的想避免它,我有什么选择?有客户端JavaScript的方式来调用λ?

answer1: 回答1:

Wrote a blog post about this.

This is totally doable. It's a matter of using AWS Cognito to call that function.

  1. You have your lambda function in place. Grand.
  2. Create a new Cognito group.
  3. Give the unauth'ed Cognito group permissions to execute the lambda function.
  4. Wire it all up in the browser. I have some example code here… https://github.com/chadbaudoin/lambda-twilio/blob/master/index.html

The “hard” part is making sure that the IAM settings for the Cognito group and the Lambda function are all set up correctly. I used this tutorial pretty heavily, but used cognito to execute so I wasn't exposing keys.

http://lg.io/2015/05/16/the-future-is-now-and-its-using-aws-lambda.html

写了一篇博客文章。

这是完全可行的。这是一个使用AWS Cognito调用该函数。

  1. You have your lambda function in place. Grand.
  2. Create a new Cognito group.
  3. Give the unauth'ed Cognito group permissions to execute the lambda function.
  4. Wire it all up in the browser. I have some example code here… https://github.com/chadbaudoin/lambda-twilio/blob/master/index.html

“硬”的部分是确保Cognito集团的IAM的设置和lambda函数都设置正确。我用这个教程相当严重,但用Cognito执行所以我不暴露的钥匙。

http://lg.io/2015/05/16/the-future-is-now-and-its-using-aws-lambda.html

javascript  amazon-web-services  aws-lambda  amazon-lambda