Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resource Not Found Error when using CLI batch-write-item

First, I want to say that I am completely new at this. When trying to use the CLI to batch load items to my dynamodb, I get the following error:

An error occurred (ResourceNotFoundException) when calling the BatchWriteItem operation: Requested resource not found

The command I run is here: aws --no-verify-ssl dynamodb batch-write-item --request-items file://program.json

The JSON file contents are here:

{
    "Program": [
        {
            "PutRequest": { 
                "Item": {
                    "programName": {"S":"Yogi Bear"},
                    "activeInd": {"S":"Y"}
                }
            }
        },
        {
            "PutRequest": { 
                "Item": {
                    "programName": {"S":"Salad for Lunch"},
                    "activeInd": {"S":"Y"}
                }
            }
        }
    ]
}

I've compared this to the examples in the documentation and I can't see a problem. I tried to simple add an individual item using put-item and got the same error. If you have any suggestions, please let me know. Thanks in advance.enter code here

like image 374
MJ2017 Avatar asked Apr 05 '17 21:04

MJ2017


1 Answers

Verify that the "Program" table exists

From the DynamoDB documentation:

ResourceNotFoundException

Message: Requested resource not found.

Example: Table which is being requested does not exist, or is too early in the CREATING state.

In your JSON file, "Program" is intended to be the name of a table that already exists. It sounds like it is failing in both this batch and in your single put case simply because the table does not exist.

Check that this table already exists with the list-tables command:

aws dynamodb list-tables

If not, create it with the create-table command.

Verify your CLI default region is the same as your table

If this table does exist, check your cli configuration to verify that you're querying in the same region that the table exists. You can check your default region like this:

aws configure get region

You can use aws configure to change your default settings, or specify --region directly on any CLI command to override your default region.

Further Reading

  • AWS Documentation - aws dynamodb batch-write-item
  • AWS Documentation - DynamoDB Error Handling
  • AWS Documentation - aws configure get
like image 123
Anthony Neace Avatar answered Oct 29 '22 15:10

Anthony Neace