I am facing an issue when I am migrating a table consisting a JSON in a column which should be inserted in as a DyanmoDB Map. The source data is in the following format
<table border="1"><tr><th>userId</th><th>brandId</th><th>createdBy</th><th>modifiedBy</th><th>preferences</th><th>version</th></tr><tr><td>TU0001</td><td>TEST BRAND</td><td>{"channel":{"S":"website"},"date":{"S": "2022-06-13T08:16:26.300Z"},"userId":{"S":"TU0001"}}</td><td>{"channel":{"S":"website"},"date":{"S": "2022-06-13T015:26:10.200Z"},"userId":{"S":"TU0001"}}</td><td>{"Colour": {"S": "Red" },"Size":{"S": "XL" }}</td><td>1</td></tr></table>
The table in DynamoDB is in the sam structure except that the JSON values are stored as MAP (dynamodb-map). When we migrate using DMS, it inserts the JSON as string value and not MAP as expected.
I have defined the transformation rule as follows:
"attribute-mappings": [
{
"target-attribute-name": "userId",
"attribute-type": "scalar",
"attribute-sub-type": "string",
"value": "${userId}"
},
{
"target-attribute-name": "brandId",
"attribute-type": "scalar",
"attribute-sub-type": "string",
"value": "${brandId}"
},
{
"target-attribute-name": "createdBy",
"attribute-type": "document",
"attribute-sub-type": "dynamodb-map",
"value": {
"M": {
"S": "${createdBy}"
}
}
},
{
"target-attribute-name": "modifiedBy",
"attribute-type": "document",
"attribute-sub-type": "dynamodb-map",
"value": {
"M": {
"S": "${modifiedBy}"
}
}
},
{
"target-attribute-name": "preferences",
"attribute-type": "document",
"attribute-sub-type": "dynamodb-map",
"value": {
"M": {
"S": "${preferences}"
}
}
},
{
"target-attribute-name": "version",
"attribute-type": "scalar",
"attribute-sub-type": "number",
"value": "${version}"
}
]
I also tried adding the map as below, and it adds an empty map in DyanmoDB.
"value": {
"M": "${preferences}"
}
Hope someone can help.