Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

208
Visualizações
Add a string to my Lambda function variable

I am trying to implement a DynamoDB single table design. I have a Lambda that's triggered by a new Cognito user with a Post Confirmation Trigger which sends the new User to my DynamoDB Table.

In the 'Item' I would like to add a string that goes before the User Sub ID which is saved to 'PK' but can't work out how to append this to the beginning.

var aws = require('aws-sdk');
var ddb = new aws.DynamoDB({apiVersion: '2012-10-08'});

exports.handler = async (event, context) => {
console.log(event);

let date = new Date();

const tableName = 'Kaleido';
const region = 'ap-southeast-2';

console.log("table=" + tableName + " -- region=" + region);

aws.config.update({region: region});

// If the required parameters are present, proceed
if (event.request.userAttributes.sub) {

    // -- Write data to DDB
    let ddbParams = {
        Item: {
            //Add 'User#' below
            "PK": {S: event.request.userAttributes.sub},
            "SK": {S: event.userName},
            "Type": "User",
            "createdAt": {S: date.toISOString()},
        },
        TableName: 'Kaleido'
    };

    // Call DynamoDB
    try {
        await ddb.putItem(ddbParams).promise();
        console.log("Success");
    } catch (err) {
        console.log("Error", err);
        context.done(null, event);
    }

    console.log("Success: Everything executed correctly");
    context.done(null, event);

} else {
    // Nothing to do, the user's email ID is unknown
    console.log("Error: Nothing was written to DDB or SQS");
    context.done(null, event);
}

};

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda