Skip to content

DynamoDB 実務Tips

Terminal window
# テーブル作成
aws dynamodb create-table \
--table-name Users \
--attribute-definitions \
AttributeName=userId,AttributeType=S \
--key-schema AttributeName=userId,KeyType=HASH \
--billing-mode PAY_PER_REQUEST
# アイテム追加
aws dynamodb put-item \
--table-name Users \
--item '{
"userId": {"S": "user123"},
"name": {"S": "John Doe"},
"email": {"S": "john@example.com"}
}'
# アイテム取得
aws dynamodb get-item \
--table-name Users \
--key '{"userId": {"S": "user123"}}'
# クエリ
aws dynamodb query \
--table-name Users \
--key-condition-expression "userId = :uid" \
--expression-attribute-values '{":uid":{"S":"user123"}}'
設計:
- パーティションキー分散
- 複合キー活用
- GSI適切に使用
パフォーマンス:
- BatchGetItem(最大100)
- BatchWriteItem(最大25)
- DAX活用
コスト:
- オンデマンド vs プロビジョニング
- TTL活用
- 不要データ削除