Skip to content

Commit a4a036e

Browse files
weirdryclaude
andcommitted
feat: add secure DynamoDB operations to db-connect CLI
- Add comprehensive DynamoDB connector with list, describe, scan, query, and get-item operations - Implement security-first design with automatic sensitive field filtering (API keys, secrets, etc.) - Add DynamoDB dependencies (@aws-sdk/client-dynamodb, @aws-sdk/lib-dynamodb) - Integrate MFA authentication for DynamoDB access using existing auth system - Include realistic examples and help text for emergency debugging scenarios - Update main README with DynamoDB usage examples and security emphasis Security features: - All DynamoDB commands automatically hide sensitive fields ([HIDDEN]) - Protected fields: encrypted_api_key, encrypted_secret_key, dek_encrypted, tokens, passwords - Generic CLI design for reliable emergency access without business logic dependencies πŸ€– Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 655f5df commit a4a036e

4 files changed

Lines changed: 479 additions & 12 deletions

File tree

β€ŽREADME.mdβ€Ž

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ A collection of command-line tools for the Fiftyten platform, designed to improv
1111
## πŸš€ Tools Available
1212

1313
### [@fiftyten/db-connect](./packages/db-connect)
14-
Simple CLI tool for connecting to Fiftyten databases via AWS Session Manager.
14+
CLI tool for database connections and DynamoDB operations via AWS Session Manager.
1515

1616
**Quick Start:**
1717
```bash
@@ -22,10 +22,12 @@ brew install postgresql awscli
2222
# 2. Install globally (pnpm - team standard)
2323
pnpm add -g @fiftyten/db-connect
2424

25-
# 3. One command for complete database access
25+
# 3. Database connections
2626
fiftyten-db psql dev -d platform
2727

28-
# That's it! Automatic tunnel + password + psql connection
28+
# 4. DynamoDB operations (sensitive fields always hidden)
29+
fiftyten-db dynamo list-tables
30+
fiftyten-db dynamo scan trading_orders --limit 10
2931
```
3032

3133
## πŸ“¦ Installation
@@ -69,20 +71,24 @@ aws --version
6971

7072
#### With pnpm
7173
```bash
72-
# One-command connection
74+
# Database connections
7375
pnpm dlx @fiftyten/db-connect psql dev -d platform
74-
75-
# Or manual tunnel
7676
pnpm dlx @fiftyten/db-connect tunnel dev -d platform
77+
78+
# DynamoDB operations
79+
pnpm dlx @fiftyten/db-connect dynamo list-tables
80+
pnpm dlx @fiftyten/db-connect dynamo scan trading_orders --limit 10
7781
```
7882

7983
#### With npm
8084
```bash
81-
# One-command connection
85+
# Database connections
8286
npx @fiftyten/db-connect psql dev -d platform
83-
84-
# Or manual tunnel
8587
npx @fiftyten/db-connect tunnel dev -d platform
88+
89+
# DynamoDB operations
90+
npx @fiftyten/db-connect dynamo list-tables
91+
npx @fiftyten/db-connect dynamo scan trading_orders --limit 10
8692
```
8793

8894
## πŸ—οΈ Development
@@ -172,7 +178,9 @@ pnpm --filter package-name publish --access public
172178

173179
## 🎯 Usage Examples
174180

175-
### One-Command Database Connection (Recommended)
181+
### Database Connections
182+
183+
#### One-Command Connection (Recommended)
176184
```bash
177185
# Connect to platform database with automatic password
178186
fiftyten-db psql dev -d platform
@@ -184,13 +192,13 @@ fiftyten-db psql dev -d copytrading
184192
fiftyten-db psql dev -d platform -p 5433
185193
```
186194

187-
### Database Discovery
195+
#### Database Discovery
188196
```bash
189197
# See what databases are available
190198
fiftyten-db databases dev
191199
```
192200

193-
### Manual Tunnel Commands (Advanced)
201+
#### Manual Tunnel Commands (Advanced)
194202
```bash
195203
# Create tunnel to platform database
196204
fiftyten-db tunnel dev -d platform
@@ -208,6 +216,33 @@ fiftyten-db info dev
208216
fiftyten-db list
209217
```
210218

219+
### DynamoDB Operations
220+
221+
#### Table Discovery
222+
```bash
223+
# List all DynamoDB tables
224+
fiftyten-db dynamo list-tables
225+
226+
# Describe table structure and keys
227+
fiftyten-db dynamo describe fiftyten-exchange-credentials-dev
228+
```
229+
230+
#### Data Operations (Sensitive Fields Always Hidden)
231+
```bash
232+
# Scan recent trading orders
233+
fiftyten-db dynamo scan trading_orders --limit 10
234+
235+
# Query all credentials for tenant 5010
236+
fiftyten-db dynamo query fiftyten-exchange-credentials-dev "tenant_id = 5010"
237+
238+
# Get specific item (composite key)
239+
fiftyten-db dynamo get-item fiftyten-exchange-credentials-dev \
240+
'{"tenant_id":"5010","credential_sk":"USER#john_doe_123#PRODUCT#COPY_TRADING#EXCHANGE#gateio"}'
241+
242+
# Get trading order details
243+
fiftyten-db dynamo get-item trading_orders "id:trd_5f8a2b3c4d5e6f7g8h9i"
244+
```
245+
211246
### Team Workflow
212247
```bash
213248
# 1. Install once globally with pnpm
@@ -261,6 +296,8 @@ Could not auto-discover MFA devices, using fallback detection
261296
**Key Features:**
262297
- πŸš€ **One-Command Connection**: `fiftyten-db psql dev -d platform` - tunnel + password + psql automatically
263298
- πŸ” **Multi-Database Support**: Connect to platform, copytrading, or any configured database
299+
- πŸ—‚οΈ **DynamoDB Operations**: List, scan, query, and get items with built-in security
300+
- πŸ”’ **Security-First Design**: Sensitive fields (API keys, secrets) always hidden
264301
- πŸ” **Database Discovery**: `fiftyten-db databases dev` to see what's available
265302
- πŸ” **Smart MFA Handling**: Auto-discovers MFA devices with single prompt
266303
- 🎯 **Single Device Auto-Selection** for seamless experience

β€Žpackages/db-connect/package.jsonβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
"@aws-sdk/client-sts": "^3.0.0",
3131
"@aws-sdk/client-iam": "^3.0.0",
3232
"@aws-sdk/client-secrets-manager": "^3.0.0",
33+
"@aws-sdk/client-dynamodb": "^3.0.0",
34+
"@aws-sdk/lib-dynamodb": "^3.0.0",
3335
"inquirer": "^9.0.0"
3436
},
3537
"devDependencies": {

0 commit comments

Comments
Β (0)