awslabs / awslabs/amazon-dynamodb-tools

[verb] `import` - import data from NoSQL sources into DynamoDB (starting with MongoDB)

Open
#108 2 comments 0 reactions 0 assignees View on GitHub
bulk_executor bulk-verb enhancement question
Dominant language
Python
Stars
181
Forks
50
Avg merge
4h 11m
Merged PRs (30d)
36

Description

A `migrate` verb would enable users to efficiently import data from NoSQL databases into DynamoDB tables, starting with MongoDB support and designed for extensibility to other NoSQL sources.

The bulk_executor already supports loading from S3-based formats via the `load` verb. The `migrate` verb extends this pattern to support live NoSQL database sources, leveraging AWS Glue's native NoSQL connectors.

## Scope

This issue focuses on **NoSQL-compatible sources**, with initial implementation for MongoDB. The design enables future contributors to easily add DocumentDB, Cassandra, and other NoSQL sources using similar connector patterns.

**Note:** For JDBC/relational source migrations (Redshift, PostgreSQL, MySQL), see the companion issue for JDBC sources.

## Proposed Usage

```bash
# Migrate from MongoDB collection to DynamoDB table
./bulk migrate --source-type mongodb \
--source-collection database.collection \
--target-table dynamodb_table \
--mongodb-connection my-glue-connection

# With optional transformation
./bulk migrate --source-type mongodb \
--source-collection orders \
--target-table Orders \
--mongodb-connection prod-mongodb \
--transformer reshape.py

# With MongoDB query filter
./bulk migrate --source-type mongodb \
--source-collection orders \
--target-table Orders \
--mongodb-connection prod-mongodb \
--filter '{"status": "completed", "date": {"$gt": "2024-01-01"}}'

# With projection to limit fields
./bulk migrate --source-type mongodb \
--source-collection orders \
--target-table Orders \
--mongodb-connection prod-mongodb \
--projection '{"order_id": 1, "customer_id": 1, "total": 1}'
```

## Key Features

- Generic `--source-type` parameter for NoSQL sources (mongodb, documentdb, cassandra, etc.)
- Leverage AWS Glue Connections for NoSQL authentication and connection management
- Reuse existing bulk_executor parallel processing and DynamoDB write logic
- Optional transformer hook for schema mapping and data reshaping
- Support for native query filters (MongoDB query syntax, CQL for Cassandra, etc.)
- Automatic data type conversion from source NoSQL to DynamoDB types
- Built-in rate limiting to respect DynamoDB throughput
- Parallel reads via Spark connector partitioning

## Initial Implementation: MongoDB

- Use Spark MongoDB connector (available in AWS Glue)
- Require `--mongodb-connection` parameter (existing Glue Connection name)
- Support `--source-collection` for collection name
- Support `--filter` for MongoDB query filter (JSON string)
- Support `--projection` for field selection
- Default 1:1 collection migration with optional transformation

## Future Extensibility

```bash
# Future: Amazon DocumentDB (MongoDB-compatible)
./bulk migrate --source-type documentdb \
--source-collection users \
--target-table Users \
--documentdb-connection my-conn

# Future: Apache Cassandra / Amazon Keyspaces
./bulk migrate --source-type cassandra \
--source-table keyspace.table \
--target-table Products \
--cassandra-connection my-conn \
--filter "WHERE category = 'electronics'"
```

## Use Cases

- Migrating from MongoDB to DynamoDB for AWS-native architecture
- Consolidating data from DocumentDB into DynamoDB
- Moving from Cassandra/Keyspaces to DynamoDB for simplified operations
- One-time or periodic data synchronization between NoSQL databases

## Implementation Approach

- Extend bulk_executor with NoSQL source support for `migrate` verb
- Use Spark NoSQL connectors (MongoDB Spark Connector, Cassandra Spark Connector)
- AWS Glue supports MongoDB connections via Glue Connections
- MongoDB connector handles connection pooling and parallel reads
- Connection details stored securely in Glue Connection
- Reuse existing DynamoDB write patterns from other verbs
- Transformer scripts handle schema mapping (source NoSQL → DynamoDB)
- Support for connector-specific partitioning strategies
- Leverage connector's native query pushdown for filtering

## Technical Notes

- AWS Glue supports MongoDB via the MongoDB Spark Connector
- MongoDB → DynamoDB migration is simpler than SQL → DynamoDB (both NoSQL)
- The existing `load` verb demonstrates the pattern for external data ingestion
- DocumentDB is MongoDB-compatible, so same connector can be used
- Cassandra requires the Cassandra Spark Connector
- Schema mapping is typically simpler for NoSQL → NoSQL migrations

This enhancement enables flexible data migration from NoSQL databases into DynamoDB, with an extensible design that can support multiple NoSQL sources over time.

---

**Suggested Labels:** `bulk-verb`, `bulk_executor`, `enhancement`, `help wanted`

Contributor guide

Open the contributing guide

Research direction

Start by reading the existing bulk_executor and the load verb, then trace how AWS Glue’s MongoDB/Spark connector would supply records and options. Done means a migrate verb supports MongoDB collection imports into DynamoDB with the listed connection, filter, projection, transformation, parallel-read, type-conversion, and rate-limiting behavior while leaving room for other NoSQL sources.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, mongodb, python, spark
Domain
backend, data-engineering, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.