Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Dynamodb Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1

I'm trying to add elements in a table in dynamodb like in the example below but when I run it I get this error message: Missing credentials in the config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1

aws.config.update({
   region: "eu-west-1",
   endpoint: "http://localhost:8080",})


  let ddb = new aws.DynamoDB.DocumentClient({
    apiVersion: "2012-08-10",
  });

  let params = {
    TableName: "NameOfTheTable",
    Item: {
      uuid: JSON.stringify(132), // random number for testing
      name: JSON.stringify(req.query.mod), //data i'm passing in
    },
  };

const addMod = ddb.put(params, function (err, data) {
  if (err) {
    console.log("Error", err);
  } else {
    console.log("Success", data);
  }
});
return res.send(addMod);

});

I think probably I'm missing the accessKeyId and the accessSecretKey but honestly, I did not understand how to set them

like image 962
Gianmarco Avatar asked Oct 22 '25 02:10

Gianmarco


1 Answers

It seems you enquire credentials for local because the SDK checks for them, this has been raised as an issue it seems.

You can get around by specifying any string supposedly. Try the below snippet.

aws.config.update({
    region: "eu-west-1",
    endpoint: "http://localhost:8080",
    accessKeyId: “xxxxxx”,
    secretAccessKey: “xxxxxx”
});
like image 147
Chris Williams Avatar answered Oct 24 '25 17:10

Chris Williams