ApsaraDB for MongoDB supports the DynamoDB protocol for sharded cluster instances running MongoDB 4.0. This page covers which DynamoDB operations, parameters, expressions, and data types are supported, along with behavioral differences you should know before migrating.
DynamoDB-compatible sharded cluster instances are no longer available for purchase. To use sharded cluster instances, use the MongoDB protocol instead. For more information, see [Notice] End of sale for DynamoDB-compatible sharded cluster instances.
Usage notes
DynamoDB protocol support applies only to sharded cluster instances running MongoDB 4.0.
Existing sharded cluster instances can have their protocol type changed to DynamoDB.
Only Virtual Private Cloud (VPC) network type is supported. No authentication is required.
Unsupported features
The following DynamoDB features are not supported. If your application relies on any of these, plan for code changes before migrating.
Billing and throughput controls
BillingMode, ProvisionedThroughput, and related metrics (ReturnConsumedCapacity, ConsumedCapacity, ItemCollectionMetrics, ReturnItemCollectionMetrics) are not supported across all operations.
Table management
ListTablesdoes not support pagination.ExclusiveStartTableName,Limit, andLastEvaluatedTableNameare ignored. All tables are returned in one response, with no limit on the number of returned records.UpdateTabledoes not supportGlobalSecondaryIndexesUPDATE actions. Only CREATE and DELETE are supported.Table-level features not supported:
Tags,SSESpecification,ReplicaUpdates,BillingMode.
Item operations
The following parameters are not supported across item operations (PutItem, UpdateItem, GetItem, DeleteItem, BatchWriteItem, BatchGetItem):
ConditionalOperatorandExpected(legacy condition syntax) — useConditionExpressioninsteadAttributesToGet— useProjectionExpressioninsteadConsistentReadAttributeUpdates(legacy update syntax) — useUpdateExpressioninstead
Query and Scan
KeyConditions,QueryFilter, andScanFilter(legacy filter syntax) — useKeyConditionExpressionandFilterExpressioninsteadSelectparameterConditionalOperatorandConsistentRead
DynamoDB Streams
DescribeStream:LimitandExclusiveStartShardIdare not supported.ListStreams:LimitandExclusiveStartStreamArnare not supported.
TableDescription data structure
The TableDescription response object returned by CreateTable, UpdateTable, DescribeTable, and DeleteTable includes the following fields.
| Field | Supported |
|---|---|
| GlobalSecondaryIndexes | Yes |
| ItemCount | Yes |
| KeySchema | Yes |
| LatestStreamArn | Yes |
| LatestStreamLabel | Yes |
| LocalSecondaryIndexes | Yes |
| StreamSpecification | Yes |
| TableName | Yes |
| TableSizeBytes | Yes |
| TableStatus | Yes |
| ArchivalSummary | No |
| AttributeDefinitions | No |
| BillingModeSummary | No |
| CreationDateTime | No |
| GlobalTableVersion | No |
| ProvisionedThroughput | No |
| Replicas | No |
| RestoreSummary | No |
| SSEDescription | No |
| TableArn | No |
| TableId | No |
DynamoDB operations compatibility
Table operations
| Operation | Parameter | Supported | Notes |
|---|---|---|---|
| CreateTable | AttributeDefinitions (required) | Yes | — |
| KeySchema (required) | Yes | — | |
| TableName (required) | Yes | Cannot contain $; cannot start with system.; must be 1–100 characters | |
| BillingMode (optional) | No | — | |
| GlobalSecondaryIndexes (optional) | Yes | — | |
| LocalSecondaryIndexes (optional) | Yes | — | |
| ProvisionedThroughput (optional) | No | — | |
| SSESpecification (optional) | No | — | |
| StreamSpecification (optional) | Yes | StreamViewType supports KEYS_ONLY (partition keys only, sort keys not supported) and NEW_IMAGE | |
| Tags (optional) | No | — | |
| Response: TableDescription | Yes | — | |
| UpdateTable | AttributeDefinitions (optional) | Yes | — |
| BillingMode (optional) | No | — | |
| GlobalSecondaryIndexesUpdates (required) | Yes | CREATE and DELETE supported; UPDATE not supported | |
| ProvisionedThroughput (optional) | No | — | |
| ReplicaUpdates (optional) | No | — | |
| SSESpecification (optional) | No | — | |
| StreamSpecification (optional) | Yes | Same StreamViewType constraints as CreateTable | |
| TableName (required) | Yes | — | |
| Response: TableDescription | Yes | — | |
| DescribeTable | TableName (required) | Yes | — |
| Response: Table | Yes | — | |
| ListTables | ExclusiveStartTableName (optional) | No | Pagination not supported; all tables returned; no limit on the number of returned records |
| Limit (optional) | No | Pagination not supported; all tables returned; no limit on the number of returned records | |
| Response: LastEvaluatedTableName | No | — | |
| Response: TableNames | Yes | — | |
| DeleteTable | TableName (required) | Yes | — |
| Response: TableDescription | Yes | — |
Item operations
| Operation | Parameter | Supported | Notes |
|---|---|---|---|
| PutItem | Item (required) | Yes | — |
| TableName (required) | Yes | — | |
| ConditionalOperator (optional) | No | — | |
| ConditionExpression (optional) | Yes | See Expression compatibility | |
| Expected (optional) | No | — | |
| ExpressionAttributeNames (optional) | Yes | See Expression compatibility | |
| ExpressionAttributeValues (optional) | Yes | See Expression compatibility | |
| ReturnConsumedCapacity (optional) | No | — | |
| ReturnItemCollectionMetrics (optional) | No | — | |
| ReturnValues (optional) | Yes | — | |
| Response: Attributes | Yes | — | |
| Response: ConsumedCapacity | No | — | |
| Response: ItemCollectionMetrics | No | — | |
| UpdateItem | Key (required) | Yes | — |
| TableName (required) | Yes | — | |
| AttributeUpdates (optional) | No | — | |
| ConditionalOperator (optional) | No | — | |
| ConditionExpression (optional) | Yes | See Expression compatibility | |
| Expected (optional) | No | — | |
| ExpressionAttributeNames (optional) | Yes | See Expression compatibility | |
| ExpressionAttributeValues (optional) | Yes | See Expression compatibility | |
| ReturnConsumedCapacity (optional) | No | — | |
| ReturnItemCollectionMetrics (optional) | No | — | |
| ReturnValues (optional) | Yes | — | |
| UpdateExpression (optional) | Yes | See Expression compatibility | |
| Response: Attributes | Yes | — | |
| Response: ConsumedCapacity | No | — | |
| Response: ItemCollectionMetrics | No | — | |
| GetItem | Key (required) | Yes | — |
| TableName (required) | Yes | — | |
| AttributesToGet (optional) | No | — | |
| ConsistentRead (optional) | No | — | |
| ExpressionAttributeNames (optional) | Yes | See Expression compatibility | |
| ProjectionExpression (optional) | Yes | See Expression compatibility | |
| ReturnConsumedCapacity (optional) | No | — | |
| Response: ConsumedCapacity | No | — | |
| Response: Item | Yes | — | |
| DeleteItem | Key (required) | Yes | — |
| TableName (required) | Yes | — | |
| ConditionalOperator (optional) | No | — | |
| ConditionExpression (optional) | Yes | See Expression compatibility | |
| Expected (optional) | No | — | |
| ExpressionAttributeNames (optional) | Yes | See Expression compatibility | |
| ExpressionAttributeValues (optional) | Yes | See Expression compatibility | |
| ReturnConsumedCapacity (optional) | No | — | |
| ReturnItemCollectionMetrics (optional) | No | — | |
| ReturnValues (optional) | Yes | — | |
| Response: Attributes | Yes | — | |
| Response: ConsumedCapacity | No | — | |
| Response: ItemCollectionMetrics | No | — | |
| BatchWriteItem | RequestItems (required) | Yes | — |
| ReturnConsumedCapacity (optional) | No | — | |
| ReturnItemCollectionMetrics (optional) | No | — | |
| Response: ConsumedCapacity | No | — | |
| Response: ItemCollectionMetrics | No | — | |
| Response: UnprocessedItems | Yes | — | |
| BatchGetItem | RequestItems (required) | Yes | AttributesToGet and ConsistentRead are not supported within Item |
| ReturnConsumedCapacity (optional) | No | — | |
| Response: ConsumedCapacity | No | — | |
| Response: Responses | Yes | — | |
| Response: UnprocessedKeys | Yes | — |
Query and Scan operations
| Operation | Parameter | Supported | Notes |
|---|---|---|---|
| Query | TableName (required) | Yes | — |
| AttributesToGet (optional) | No | — | |
| ConditionalOperator (optional) | No | — | |
| ConsistentRead (optional) | No | — | |
| ExclusiveStartKey (optional) | Yes | — | |
| ExpressionAttributeNames (optional) | Yes | See Expression compatibility | |
| ExpressionAttributeValues (optional) | Yes | See Expression compatibility | |
| FilterExpression (optional) | Yes | See Expression compatibility | |
| IndexName (optional) | Yes | — | |
| KeyConditionExpression (optional) | Yes | See Expression compatibility | |
| KeyConditions (optional) | No | — | |
| Limit (optional) | Yes | — | |
| ProjectionExpression (optional) | Yes | See Expression compatibility | |
| QueryFilter (optional) | No | — | |
| ReturnConsumedCapacity (optional) | No | — | |
| ScanIndexForward (optional) | Yes | — | |
| Select (optional) | No | — | |
| Response: ConsumedCapacity | No | — | |
| Response: Count | Yes | — | |
| Response: Items | Yes | — | |
| Response: LastEvaluatedKey | Yes | — | |
| Response: ScannedCount | Yes | — | |
| Scan | TableName (required) | Yes | — |
| AttributesToGet (optional) | No | — | |
| ConditionalOperator (optional) | No | — | |
| ConsistentRead (optional) | No | — | |
| ExclusiveStartKey (optional) | Yes | — | |
| ExpressionAttributeNames (optional) | Yes | See Expression compatibility | |
| ExpressionAttributeValues (optional) | Yes | See Expression compatibility | |
| FilterExpression (optional) | Yes | See Expression compatibility | |
| IndexName (optional) | Yes | — | |
| Limit (optional) | Yes | — | |
| ProjectionExpression (optional) | Yes | See Expression compatibility | |
| ReturnConsumedCapacity (optional) | No | — | |
| ScanFilter (optional) | No | — | |
| Segment (optional) | Yes | — | |
| Select (optional) | No | — | |
| TotalSegments (optional) | Yes | — | |
| Response: ConsumedCapacity | No | — | |
| Response: Count | Yes | — | |
| Response: Items | Yes | — | |
| Response: LastEvaluatedKey | Yes | — | |
| Response: ScannedCount | Yes | — |
DynamoDB Streams compatibility
| Operation | Parameter | Supported | Notes |
|---|---|---|---|
| DescribeStream | StreamArn (required) | Yes | — |
| Limit (optional) | No | — | |
| ExclusiveStartShardId (optional) | No | — | |
| Response: StreamDescription | Yes | Differs from Amazon DynamoDB in three ways: (1) StartingSequenceNumber is fixed to unknown; (2) EndingSequenceNumber is a timestamp; (3) ShardId is fixed to arn:alibaba:mongo-dynamodb@shard-only-1 because the instance has only one shard node | |
| ListStreams | TableName (optional) | Yes | — |
| Limit (optional) | No | — | |
| ExclusiveStartStreamArn (optional) | No | — | |
| Response: Streams | Yes | Up to one stream per table | |
| GetShardIterator | StreamArn (required) | Yes | — |
| ShardId (required) | Yes | Fixed to arn:alibaba:mongo-dynamodb@shard-only-1 | |
| ShardIteratorType (required) | Yes | Only LATEST and AFTER_SEQUENCE_NUMBER are supported | |
| SequenceNumber (optional) | Yes | Valid only when ShardIteratorType is AFTER_SEQUENCE_NUMBER; value can be a 32-bit timestamp in seconds | |
| Response: ShardIterator | Yes | — | |
| GetRecords | ShardIterator (required) | Yes | — |
| Limit (optional) | Yes | When not specified, each page returns 101 entries (not 1 MB of data as in Amazon DynamoDB) | |
| Response: Records | Yes | — |
Compatibility details of expressions
Attribute names containing a period (.)
In Amazon DynamoDB, an attribute name containing . is treated as a scalar attribute when the expression attribute name maps to all elements in a document path, or as a nested attribute otherwise. In ApsaraDB for MongoDB, scalar attributes containing . cannot be processed in query or projection expressions.
Projection expressions
Only one-dimensional arrays are supported. When a projection expression references a single array element, all other fields are also returned.
Condition expressions
The DynamoDB condition expression syntax is supported with the following constraints:
condition-expression ::=
operand comparator operand
| operand BETWEEN operand AND operand
| operand IN ( operand (',' operand (, ...) ))
| function
| condition AND condition
| condition OR condition
| NOT condition
| ( condition )
comparator ::=
=
| <>
| <
| <=
| >
| >=
function ::=
attribute_exists (path)
| attribute_not_exists (path)
| attribute_type (path, type)
| begins_with (path, substr)
| contains (path, operand)
| size (path)Constraints:
operand1 comparator operand2:operand1must be apath;operand2must be an expression attribute value.operand1 BETWEEN operand2 AND operand3:operand1must be apath; all other operands must be expression attribute values.operand1 IN (operand2, ...):operand1must be apath; all other operands must be expression attribute values.size(path):pathmust be of the STRING type (for length) or SET/LIST type (for size). BINARY and MAP types are not supported.
Update expressions
The DynamoDB update expression syntax is supported with the following constraints:
update-expression ::=
[ SET action [, action] ... ]
[ REMOVE action [, action] ...]
[ ADD action [, action] ... ]
[ DELETE action [, action] ...]
set-action ::=
path = value
value ::=
operand
| operand '+' operand
| operand '-' operand
operand ::=
path | function
function ::=
if_not_exists (path, value)
| list_append (list1, list2)
remove-action ::=
path
add-action ::=
path value
delete-action ::=
path valueSET action constraints:
SET path = operand:operandcannot be apath.SET path = operand1 + operand2orSET path = operand1 - operand2:operand1must be apath. Only field increment and decrement are supported.SET path = if_not_exists(path, value): Bothpathreferences must be equal, andvaluemust be an expression attribute value. Partial updates are not supported when multiple conditions are specified concurrently — all conditions must be met for the expression to execute.SET path = list_append(list1, list2): One oflist1orlist2must equalpath; the other must be an expression attribute value.
REMOVE action constraint:
When a list element is removed, null replaces it. The list size remains unchanged and remaining elements are not shifted.
Data type mappings
Amazon DynamoDB and ApsaraDB for MongoDB use different data types. The following table shows how DynamoDB types map to MongoDB types in DynamoDB-compatible instances.
| DynamoDB type | MongoDB type |
|---|---|
| B | Binary data |
| BOOL | Boolean |
| BS | Array (see note below) |
| L | Array |
| M | Object |
| N | Double |
| NS | Array (see note below) |
| NULL | Null |
| S | String |
| SS | Array (see note below) |
In Amazon DynamoDB, binary sets (BS), number sets (NS), and string sets (SS) deduplicate values automatically — for example, inserting1,2,2,3into an NS results in1,2,3. DynamoDB-compatible ApsaraDB for MongoDB instances do not support data deduplication for these types and store them as plain arrays. This behavior will be optimized in a future release.