Sam Min Wong
Sam Min Wong

Reputation: 151

Dynamo DB: Difference between creating table with and without '--endpoint-url'

I am trying to build an app using scrapy and store the result inside DynamoDB. The boto3 doc provided sample code to create a table: DynamoDB — Boto 3 documentation

After I run the script, I was able to see this:

    $ aws dynamodb list-tables
    {
    "TableNames": ["users"]
    }

At this point I just realized I didn't download DynamoDB, so I downloaded and set it up with DynamoDB (Downloadable Version) on Your Computer - Amazon DynamoDB.

Following Step 1: Create a Table - Amazon DynamoDB to add my first table, I got this:

    $ aws dynamodb list-tables --endpoint-url http://localhost:8000
    {
    "TableNames": "Movies"
    }

Now I am confused:

  1. How can I create a table without running the downloadable version of Dynamo DB?
  2. What is the difference between with and without the 'endpoint' option?

Because in the boto3 doc:

    table = dynamodb.create_table(...)

and in AWS Doc:

    dynamodb = boto3.resource('dynamodb', region_name='us-west-2', endpoint_url="http://localhost:8000")

FYI, I have no problem accessing the shell: http://localhost:8000/shell/

Upvotes: 0

Views: 728

Answers (2)

Nadav Har'El
Nadav Har'El

Reputation: 13731

sc0rp1on's answer is of course correct, but in case the original poster needs an even more explicit answer, I thought I would add some details:

DynamoDB is, essentially, a service - a database running by Amazon in their own data centers, to which your client connects through HTTP requests over the Internet, and you pay Amazon per request. You don't need to install anything to use this service, but you do need to configure it (to register to the service, how you will pay for it, put your account details in a configuration file, etc.) and I guess you did this sometime in the past or the commands you mentioned would not have worked.

If you don't specify an endpoint, by default the Amazon commands look in $HOME/.aws/config (which again, which you probably have previously set up and forgot). For example, if you have there "region = us-east-1", the "endpoint URL" is automatically calculated from that, to be "http://dynamodb.us-east-1.amazonaws.com".

As you noticed, you can indeed download a local version of DynamoDB and install it on your own machine. This is mainly designed for testing your application - it's not supposed to be useful for doing real production database work. When you want to test your application against a local DynamoDB installed on the local machine, you can indeed pass the endpoint URL of "http://localhost:8000", meaning the server running on the current machine (localhost) on port 8000.

Upvotes: 1

sc0rp1on
sc0rp1on

Reputation: 368

You set the endpoint to indicate that you are creating the table in the downloadable version of DynamoDB on your computer.

Reference

That means, if you remove endpoint_url, the table will be created in the Amazon DynamoDB service and when endpoint_url is present it will be created on the downloaded version.

Upvotes: 2

Related Questions