An AWS CLI tutorial that demonstrates Dynamodb operations.
bash dynamodb-batch-ops.shTo auto-run with cleanup:
echo 'y' | bash dynamodb-batch-ops.sh- Creating table"; aws dynamodb create-table --table-name "$T" --key-schema AttributeName=pk,KeyType=HASH --attribute-definitions AttributeName=pk,AttributeType=S --billing-mode PAY_PER_REQUEST > /dev/null; aws dynamodb wait table-exists --table-name "$T
- Batch write (25 items)"; aws dynamodb batch-write-item --request-items "{"$T":[$(for i in $(seq 1 25); do echo -n "{"PutRequest":{"Item":{"pk":{"S":"item-$i"},"data":{"S":"value-$i"}}}}"; [ $i -lt 25 ] && echo -n ","; done)]}
- Batch get (5 items)"; aws dynamodb batch-get-item --request-items "{"$T":{"Keys":[{"pk":{"S":"item-1"}},{"pk":{"S":"item-5"}},{"pk":{"S":"item-10"}},{"pk":{"S":"item-15"}},{"pk":{"S":"item-20"}}]}}" --query "Responses."$T"[].{pk:pk.S,data:data.S}
- Scan count"; aws dynamodb scan --table-name "$T
- Table
The script prompts you to clean up resources when it finishes.
Free tier eligible for most operations. Clean up resources after use to avoid charges.