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

135
Vistas
Can the Key value for DynamoDB be a variable or does it have to be hardcoded?

This is my code:

var ddb = new AWS.DynamoDB();

const tableName = 'Table_One';

  let client_id = "a3bdso310";
  console.log(`"${client_id}"`);

  var params = {
      TableName: tableName,
      Key: {
        'client_id': {S: client_id}
      },
  };
  

  ddb.getItem(params, function(err, data) {
      if (err) {
          console.error("Unable to read item. Error JSON:", JSON.stringify(err, null, 2));
      } else {
          let str_client_data = JSON.stringify(data.Item.client_data.S);
          let parsed_client_data_str = JSON.parse(str_client_data);
          let parsed_data = JSON.parse(parsed_client_data_str)
          res.send(parsed_data);
      }
  });

I am getting an error when I try to perform a GetItem using DynamoDB SDK: "The provided key element does not match the schema". Whenever I replace {S: client_id} with the actual value like this {S: "a3bdso310"} it works just find. Can the "Key" value not be a variable? What is even weirder is that when I test this locally it works just fine, the issue is only occurring when I deploy my local project to an EC2. So basically when I run this project on my local machine, everything is the same, the only difference I can think of when running it in an EC2 instance is maybe the fact that the EC2 instance has to have permissions to perform operations on my DynamoDB table. But I already gave it permissions, and other operations work fine that don't require a key (e.g. scan). Is there a solution around this?

about 4 years ago · Juan Pablo Isaza
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