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

609
Visualizações
One or more parameter values were invalid: dynamodb
const dynamoDBConfig = require("../../config/dynamodb");
var AWS = require("aws-sdk");
AWS.config.update(dynamoDBConfig.aws_remote_config);
var dynamodb = new AWS.DynamoDB();

var params = {
    TableName : "year",
    KeySchema: [       
        { AttributeName: "year", KeyType: "HASH"},  //Partition key
        { AttributeName: "title", KeyType: "RANGE" }  //Sort key
    ],
    // other properties, it is the same every time
};
dynamodb.createTable(params, function(err, data) {
    if (err) {
        console.error("Unable to create table. Error JSON:", JSON.stringify(err, null, 2));
    } else {
        console.log("Created table. Table description JSON:", JSON.stringify(data, null, 2));
    }
});

You can notice my primary key is year, AttributeName: "year", KeyType: "HASH". If i just change table name too anything it workes fine. But, when i change,AttributeName: "year", KeyType: "HASH" to AttributeName: "anything", KeyType: "HASH" then it is generating error.

Unable to create table. Error JSON: {
  "message": "One or more parameter values were invalid: Some index key attributes are not defined in AttributeDefinitions. Keys: [test, title], AttributeDefinitions: [title, year]",
  "code": "ValidationException",
  "time": "2021-01-28T05:33:33.723Z",
  "requestId": "H4S1BQ5LB4G46S594UTBK4QMVRVVASDASSFGFGF4KQNSO5AEMVJF66Q9ASUAAJG",
  "statusCode": 400,
  "retryable": false,
  "retryDelay": 4.143072370771728
}

What is wrong, when I change the name of the primary key attribute?

Full params

var params = {
    TableName : "iam",
    KeySchema: [       
        { AttributeName: "test", KeyType: "HASH"},  //Partition key
        { AttributeName: "title", KeyType: "RANGE" }  //Sort key
    ],
    AttributeDefinitions: [       
        { AttributeName: "year", AttributeType: "N" },
        { AttributeName: "title", AttributeType: "S" }
    ],
    ProvisionedThroughput: {       
        ReadCapacityUnits: 10, 
        WriteCapacityUnits: 10
    }
};
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The issue is cause by the fact that your KeySchema does not match AttributeDefinitions.

In the KeySchema you have test, while in your AttributeDefinitions you have year. This obviously leads to your issue, as you can't have AttributeDefinitions which are not part of your KeySchema, nor part of schema of Local or Global Secondary Indices.

over 4 years ago · Santiago Trujillo Relatório
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