# DynamoDB to Cosmos DB NoSQL

[![Adiom on Azure Marketplace](https://assetsprod.microsoft.com/mpn/en-us/ms-azure-marketplace.png)](https://azuremarketplace.microsoft.com/en/marketplace/apps/adiom.adiom_dsync_vm_dynamo)

### Prerequisites

1. **Set up Temporal and SigNoz** (or another OTEL collector). You can follow the instructions in [](https://docs.adiom.io/enterprise/running-dsynct "mention")
2. **Obtain DynamoDB credentials** - you can create a new dedicated user in IAM with AmazonDynamoDBFullAccess permissions, and [create security keys for it](https://docs.aws.amazon.com/sdkref/latest/guide/access-iam-users.html).
3. **Obtain Cosmos DB credentials** - URI and Primary Key ("Settings" -> "Keys" in the left menu)
4. [**Enable Streams**](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Streams.html#Streams.Enabling) **in DynamoDB** - for the tables being migrated. Use "New image".

### Worker VM setup

<pre class="language-bash"><code class="lang-bash"><strong>## Set variables
</strong><strong>export SIGNOZ=http://&#x3C;SIGNOZ_HOST>:4317
</strong><strong>export TEMPORAL=&#x3C;TEMPORAL_HOST>:7233
</strong><strong>export AWS_ACCESS_KEY_ID=&#x3C;...>
</strong><strong>export AWS_SECRET_ACCESS_KEY=&#x3C;...>
</strong><strong>export AWS_REGION=&#x3C;...>
</strong><strong>export COSMOS_URI=&#x3C;...> #e.g. https://cosmos-nosql-west.documents.azure.com:443/
</strong><strong>export COSMOS_KEY=&#x3C;...>
</strong>
<strong>## Create internal network for Docker
</strong>docker network create mynet

## Cosmos DB NoSQL Connector
nohup docker run \
--network mynet --name cosmosnosqlconnector \
-e OTEL_EXPORTER_OTLP_ENDPOINT=$SIGNOZ \
markadiom/cosmosnosqlconnector 8089 $COSMOS_URI $COSMOS_KEY 2>&#x26;1 > /tmp/java.log &#x26;

## Worker
nohup docker run \
--network mynet --name dsyncworker \
-e OTEL_EXPORTER_OTLP_ENDPOINT=$SIGNOZ \
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
-e AWS_REGION=$AWS_REGION \
markadiom/dsynct worker \
--namespace-mapping "dynamo_table:cosmos_db.container,dynamo_table1:cosmos_db.container1" \
--concurrent-activities 4 --sync-writer-workers 8 \
dynamodb \
grpc://cosmosnosqlconnector:8089 --insecure \
temporal --host-port $TEMPORAL \
app --otel 2>&#x26;1 > /tmp/dsynct-worker.log &#x26;
</code></pre>

{% hint style="info" %}
If data transformations are needed, you can use the embedded [YAML transformer](https://docs.adiom.io/enterprise/running-dsynct/data-transformations).
{% endhint %}

### Running the workflow

```bash
## Runner 
docker run \
--name dsyncrunner \
-p 8080:8080 \
-e OTEL_EXPORTER_OTLP_ENDPOINT=$SIGNOZ \
markadiom/dsynct run \
--namespace "dynamo_table" --namespace "dynamo_table1" \
temporal --host-port $TEMPORAL \
app --otel --host-port 0.0.0.0:8080
```
