Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

301
Views
Receive data from website then trigger lambda send email and backup to DynamoDB

I am beginner, I found two instructions on the internet to get data ( Contact us - Email, Phone, etc ) to AWS - Lambda then send to my email

https://aws.amazon.com/blogs/architecture/create-dynamic-contact-forms-for-s3-static-websites-using-aws-lambda-amazon-api-gateway-and-amazon-ses/

And another one to make a AWS - Lambda function to send to Dynamo to back up.

https://www.vairix.com/tech-blog/get-and-put-data-using-lambda-and-dynamodb-simple-and-clear

I put them together, but they don't connect. For example, Lamba trigger to send info from website to my email but the other function wont collect the item to send it to Dynamo

Lambda to send email:

var AWS = require('aws-sdk');
var ses = new AWS.SES();
 
var RECEIVER = 'contactus@example.com';
var SENDER = 'contactus@example.com';

var response = {
 "isBase64Encoded": false,
 "headers": { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': 'example.com'},
 "statusCode": 200,
 "body": "{\"result\": \"Success.\"}"
 };

exports.handler = function (event, context) {
    console.log('Received event:', event);
    sendEmail(event, function (err, data) {
        context.done(err, null);
    });
};
 
function sendEmail (event, done) {
    var params = {
        Destination: {
            ToAddresses: [
                RECEIVER
            ]
        },
        Message: {
            Body: {
                Text: {
                    Data: 'name: ' + event.name + '\nphone: ' + event.phone + '\nemail: ' + event.email + '\ndesc: ' + event.desc,
                    Charset: 'UTF-8'
                }
            },
            Subject: {
                Data: 'Website Referral Form: ' + event.name,
                Charset: 'UTF-8'
            }
        },
        Source: SENDER
    };
    ses.sendEmail(params, done);
}

Lambda to store information in DynamoDB:

"use strict";

AWS.config.update({ region: "us-east-1" });


exports.handler = async() => {

const documentCilent = new AWS.DynamoDB.DocumentClient({region: "us-east-1"});

const params = {
    TableName: "Users",
    
    //  This part, I need the variable connect with the top part. 
    Item:{
      id : "test",     
      name: "name",
      phone: "phone",
      desc: "desc",
      email: "email"
      
      
    }
  
};

try {
    const data = await documentCilent.put(params).promise();
    console.log(data);

} catch (err) {
    console.log(err);
}
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Lambda's are independent than each other and only fire upon receiving an Event to do so. This Event can be several things - It can be an Event sent to the lambda from an API Gateway (this is what connecting your Api to your Lambda does - gives a target for the Api Event to go to). It can be an event generated by your SDK (using your languases SDK to invoke another lambda). It can be from a DynamoDB stream or an S3 put_object event.

Pretty much any thing that happens in AWS resources outputs an event of some kind, and with the right commands/setups you can have a Lambda listening for that event.

In this situation however, as these are both very light weight, it would just be more cost effective to combine them under one lambda. API gets the information, sends it to the lambda which fires an email and adds it to the Dynamodb. Anything else in this situation is kinda overkill and would increase your costs.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!