Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

303
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda