Summary:
Dynamo DB commands from the CLI do not work when real credentials are set up. The 'endpoint-url' flag should work around this and recognize that localhost endpoints can be hit with no credentials given the default setup of the AWS Dynamo Docker image.
Output of command after setting credentials: An error occurred (ResourceNotFoundException) when calling the DescribeTable operation: Cannot do operations on a non-existent table
Is there a fix or workaround for this?
System:
MacOS Monterey version 12.0.1,
Macbook Pro - M1 - 2020
'aws --version' ->
aws-cli/2.4.11 Python/3.9.10 Darwin/21.1.0 source/arm64 prompt/off
To reproduce:
-- Start from a terminal that does NOT have AWS Credentials set up via environment variables or anything else
-- Start up a local Dynamo DB Instance on Docker:
docker pull amazon/dynamodb-local
docker run -p 8000:8000 --name=ddblocal -d amazon/dynamodb-local
-- Create a table:
aws dynamodb create-table --attribute-definitions "[{ \"AttributeName\": \"key\", \"AttributeType\": \"S\"}, { \"AttributeName\": \"valueA\", \"AttributeType\": \"S\"}]" --table-name test_table --key-schema "[{\"AttributeName\": \"key\", \"KeyType\": \"HASH\"}, {\"AttributeName\": \"valueA\", \"KeyType\": \"RANGE\"}]" --endpoint-url "http://localhost:8000" --provisioned-throughput "{\"ReadCapacityUnits\": 100, \"WriteCapacityUnits\": 100}" --region local
-- Query the table (to prove it works):
aws dynamodb describe-table --table-name test_table --region local --endpoint-url "http://localhost:8000"
-- Set your real AWS Credentials:
export AWS_ACCESS_KEY_ID="<REAL KEY ID HERE>"
export AWS_SECRET_ACCESS_KEY="<REAL SECRET KEY HERE>"
export AWS_SESSION_TOKEN="REAL TOKEN HERE>"
-- Query the table again (This one fails for me - see output above)
aws dynamodb describe-table --table-name test_table --region local --endpoint-url "http://localhost:8000"