Home > Blockchain >  Resource not found querying dynamodb
Resource not found querying dynamodb

Time:06-05

I am trying to access a DynamoDb table, but I keep getting a "Resource not found" error.

The table is defined as follows, note that the table is Active and the Region is Paris (eu-west-3)

enter image description here

The code I am using:

export class EncuestaComponent implements OnInit {

  [...]
  client: DynamoDBClient = new DynamoDBClient({
    region : 'eu-west-3',
    credentials: {
      accessKeyId: '[REDACTED]',
      secretAccessKey: '[REDACTED]'
    }
  });
  [...]
  onDbClick() {
    const commandParams = {};
    const input: BatchExecuteStatementInput = {
      Statements: [
        {Statement: "SELECT opciones FROM encuesta.encuesta WHERE id = 'user.1'"}
      ],
    }
    const command = new BatchExecuteStatementCommand(input);
    this.client.send(command).
      then(data => console.log(data.Responses![0].Error)).
      catch(error => {console.log("Error"); console.log(error)});
  }

And, in the console, it shows that the then method has been executed, but the message printed is {Code: 'ResourceNotFound', Message: 'Requested resource not found'}

What am I doing wrong?

CodePudding user response:

In PartiQL for DynamoDB, when you do select * from something.else means that you want it to query an index named else on table named something. Either you need to do one of the following:

  • escape the .
  • surround the table name with quotes
  • create a new table with a different name

I am not in front of my computer or i would figure out which it is for you, but this is where I'd start.

CodePudding user response:

Here is something that might be causing the problem.

Can you confirm that

  1. the accessKey that you are using have permission to read from the DynamoDB table?
  2. that the accessKey has not expired and can be used?

Here are a few things that can help you test out the functionality try adding the key in ~/.aws/credentials and running this command.

aws dynamodb scan --table-name encuesta.encuesta

and confirm that it is indeed showing up the table content and not getting an access denied error.

  • Related