Database
NoSQL — DynamoDB, Cosmos DB, Firestore — drive it with the real cloud SDK
Database
Emulates NoSQL databases: DynamoDB (AWS), Cosmos DB (Azure), Firestore (GCP).
| Provider | Service | SDK-compat | Driver |
|---|---|---|---|
| AWS | DynamoDB | ✓ Live | aws.DynamoDB |
| Azure | Cosmos DB | ✓ Live | azure.CosmosDB |
| GCP | Firestore | ✓ Live | gcp.Firestore |
Use the real SDK (recommended)
import (
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
"github.com/stackshy/cloudemu"
awsserver "github.com/stackshy/cloudemu/server/aws"
)
cloud := cloudemu.NewAWS()
ts := httptest.NewServer(awsserver.New(awsserver.Drivers{DynamoDB: cloud.DynamoDB}))
client := dynamodb.NewFromConfig(cfg, func(o *dynamodb.Options) {
o.BaseEndpoint = aws.String(ts.URL)
})
client.CreateTable(ctx, &dynamodb.CreateTableInput{
TableName: aws.String("Users"),
AttributeDefinitions: []types.AttributeDefinition{
{AttributeName: aws.String("id"), AttributeType: types.ScalarAttributeTypeS},
},
KeySchema: []types.KeySchemaElement{
{AttributeName: aws.String("id"), KeyType: types.KeyTypeHash},
},
BillingMode: types.BillingModePayPerRequest,
})
client.PutItem(ctx, &dynamodb.PutItemInput{
TableName: aws.String("Users"),
Item: map[string]types.AttributeValue{
"id": &types.AttributeValueMemberS{Value: "u1"},
"name": &types.AttributeValueMemberS{Value: "Alice"},
},
})Same shape with azcosmos (Azure) and cloud.google.com/go/firestore (GCP). See the SDK-Compat Server page for the full quick starts.
Operations supported via SDK-compat
DynamoDB: CreateTable, DeleteTable, DescribeTable, ListTables, PutItem, GetItem, DeleteItem, UpdateItem (SET/REMOVE), Query, Scan (with FilterExpression), BatchWriteItem, BatchGetItem, TransactWriteItems.
Cosmos DB: Databases, Containers, Documents — full CRUD with x-ms-documentdb-* headers + query.
Firestore: :commit, :batchGet, :runQuery, document CRUD via the REST data plane.
Realistic behaviors
- TTL expiry: items with TTL attributes expire on read.
- Numeric-aware comparisons: filters compare
"10" > "9"correctly using numeric ordering, not string ordering. - Stream / change feed:
PutItem/UpdateItem/DeleteItemproduce stream records (INSERT / MODIFY / REMOVE) when streams are enabled. - Global Secondary Indexes:
CreateIndex,DescribeIndex,DeleteIndex; queries can target a GSI viaQueryInput.IndexName.
Alternative: Portable Go API
import dbdriver "github.com/stackshy/cloudemu/database/driver"
aws.DynamoDB.CreateTable(ctx, dbdriver.TableConfig{
Name: "Users", PartitionKey: "id",
})
aws.DynamoDB.PutItem(ctx, "Users", map[string]any{"id": "u1", "name": "Alice"})
item, _ := aws.DynamoDB.GetItem(ctx, "Users", map[string]any{"id": "u1"})