-
Notifications
You must be signed in to change notification settings - Fork 0
/
ddb_cli_examples.cli
51 lines (42 loc) · 1.5 KB
/
ddb_cli_examples.cli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# https://docs.aws.amazon.com/ko_kr/cli/latest/reference/dynamodb/index.html
# https://www.aws.training/Details/eLearning?id=65040
# Exploring the DynamoDB API and the AWS SDKs
# List of tables
aws dynamodb list-tables --endpoint-url http://localhost:8000
# Create a table
# PK=year, SK=title
aws dynamodb create-table \
--table-name Movies \
--attribute-definitions \
AttributeName=year,AttributeType=N \
AttributeName=title,AttributeType=S \
--key-schema \
AttributeName=year,KeyType=HASH \
AttributeName=title,KeyType=RANGE \
--billing-mode PROVISIONED \
--provisioned-throughput \
ReadCapacityUnits=10,WriteCapacityUnits=10 \
--endpoint-url http://localhost:8000
# Write an item
aws dynamodb put-item \
--table-name Movies \
--item \
'{"year": {"N": "1900"},
"title": {"S": "Example 1"}}' \
--endpoint-url http://localhost:8000
# Query a table
# * "year" is a reserved word in DynamoDB
aws dynamodb query \
--endpoint-url http://localhost:8000 \
--table-name Movies \
--key-condition-expression "#y = :yr" \
--projection-expression "title,#y" \
--expression-attribute-names '{"#y": "year"}' \
--expression-attribute-values '{":yr": {"N": "1900"}}'
# Scan a table
aws dynamodb scan \
--endpoint-url http://localhost:8000 \
--table-name Movies \
--filter-expression "title = :name" \
--expression-attribute-values '{":name": {"S":"Example 1"}}' \
--return-consumed-capacity 'TOTAL'