Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use aws-cli with local dynamoDB ?

Tags:

I am struggling with using aws-cli with dynamoDB running on my local machine, could anyone please help.

DynamoDB Local with the following configuration:

Port:   8000 InMemory:   false DbPath: null SharedDb:   true shouldDelayTransientStatuses:   false CorsParams: * 

any help appreciated.

like image 687
Alok G. Avatar asked Feb 16 '16 09:02

Alok G.


People also ask

How do I access DynamoDB locally?

To access DynamoDB running locally, use the --endpoint-url parameter. The following is an example of using the AWS CLI to list the tables in DynamoDB on your computer. The AWS CLI can't use the downloadable version of DynamoDB as a default endpoint. Therefore, you must specify --endpoint-url with each AWS CLI command.

Can you use DynamoDB locally?

DynamoDB Local is available as a download (requires JRE), as an Apache Maven dependency, or as a Docker image. If you prefer to use the Amazon DynamoDB web service instead, see Setting up DynamoDB (web service).

How get data from DynamoDB to AWS CLI?

To run the dynamodb commands, you need to: AWS CLI installed, see Installing or updating the latest version of the AWS CLI for more information. AWS CLI configured, see Configuration basics for more information. The profile that you use must have permissions that allow the AWS operations performed by the examples.


2 Answers

From the documentation:

Using the AWS CLI with Downloadable DynamoDB

The AWS CLI can interact with DynamoDB running on your computer. To enable this, add the --endpoint-url parameter to each command:

--endpoint-url http://localhost:8000

Here is an example, using the AWS CLI to list the tables in a local database:

aws dynamodb list-tables --endpoint-url http://localhost:8000 

Note: if you don't have any AWS credentials configured yet, the command above may fail with You must specify region or Unable to locate credentials error. For the local connection any credentials would work, so arbitrary values can be used, for example, like this:

AWS_ACCESS_KEY_ID=X AWS_SECRET_ACCESS_KEY=X aws dynamodb list-tables --endpoint-url http://localhost:8000 --region x 
like image 175
Boris Serebrov Avatar answered Sep 21 '22 17:09

Boris Serebrov


All is need is to run aws configure:

aws configure AWS Access Key ID [None]: "fakeMyKeyId" AWS Secret Access Key [None]: "fakeSecretAccessKey" Default region name [None]: x Default output format [None]: 

After that.

aws dynamodb list-tables --endpoint-url http://localhost:8000  {    "TableNames": [] } 
like image 25
Kalenda Avatar answered Sep 19 '22 17:09

Kalenda