Search code examples
amazon-dynamodbaws-clidynamo-local

Can I use AWS CLI to create a dynamodb table in the local emulator?


Is there a way to use the following

aws dynamodb create-table --table-name TableName l --attribute-definitions AttributeName=Id,AttributeType=S --key-schema AttributeName=Id,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5

to create the table on the local dynamo emulator?


Solution

  • Yes, you need to use the --endpoint-url option.

    Quoting from AWS CLI documentation:

    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
    

    If DynamoDB is using a port number other than the default (8000), you will need to modify the --endpoint-url value accordingly.

    Note At this time, the AWS CLI cannot use the downloadable version of DynamoDB as a default endpoint; therefore, you will need to specify --endpoint-url with each CLI command.