7

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?

1

1 Answer 1

9

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

Sign up to request clarification or add additional context in comments.

3 Comments

Did you mean to leave this line in your code? // AWS.config.update({ // region: 'us-east-1', // accessKeyId: 'something', // secretAccessKey: 'somethingelsethatlooksimportant' // });
@greg_diesel it seems to be an invalid access key, so that's good.
Worked like a charm, thanks. I didn't use a Cognito group, looks like a AWS user does the trick as well

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.