Cosmos DB for PostgreSQL
In-memory control plane for Azure Cosmos DB for PostgreSQL (Citus) — clusters, firewall rules, roles, and configurations, driven with the real SDK
azr Cosmos DB for PostgreSQL
Emulates the control plane of Azure Cosmos DB for PostgreSQL (distributed Postgres on Citus) — the ARM API that provisions a server group (a coordinator plus worker nodes), manages its firewall rules and roles, tunes server parameters, and wires private endpoints. The SQL surface itself is out of scope; this models the provisioning and lifecycle API.
Reach for it in tests when your provisioning or IaC code creates a cluster, scales nodes, restarts/stops/starts it, promotes a read replica, or adds firewall rules — without a real (billed) cluster. Served as ARM REST/JSON under Microsoft.DBforPostgreSQL/serverGroupsv2, so a real armcosmosforpostgresql client with a custom endpoint works unchanged.
| Provider | Service | SDK-compat | Driver |
|---|---|---|---|
| Azure | Cosmos DB for PostgreSQL (Citus) | ✓ Live | azure.CosmosPostgreSQL |
Drive it with the real SDK#
Stand up the Azure SDK-compat server and point an armcosmosforpostgresql client factory at it. Create/update RPCs return the resource inline with a terminal provisioningState, so the SDK's LRO pollers complete:
import (
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmosforpostgresql/armcosmosforpostgresql"
"github.com/stackshy/cloudemu/v2"
azureserver "github.com/stackshy/cloudemu/v2/server/azure"
)
cp := cloudemu.NewAzure()
ts := httptest.NewTLSServer(azureserver.New(azureserver.Drivers{
CosmosPostgreSQL: cp.CosmosPostgreSQL,
}))
defer ts.Close()
// armcosmosforpostgresql.NewClientFactory(subID, cred, opts) with opts pointing
// Cloud.ResourceManager at ts.URL and Transport at ts.Client() — see the SDK-Compat page.
cc := factory.NewClustersClient()
poller, _ := cc.BeginCreate(ctx, "rg1", "pg1", armcosmosforpostgresql.Cluster{
Location: to.Ptr("eastus"),
Properties: &armcosmosforpostgresql.ClusterProperties{
AdministratorLoginPassword: to.Ptr("s3cret!"),
CoordinatorVCores: to.Ptr[int32](4),
NodeCount: to.Ptr[int32](2),
},
}, nil)
created, _ := poller.PollUntilDone(ctx, nil)See the SDK-Compat Server page for the Azure ARM/TLS setup.
Call the driver directly#
For in-process setup or assertions you can skip the HTTP hop and call the driver:
import cpgdriver "github.com/stackshy/cloudemu/v2/services/cosmospostgresql/driver"
cluster, _, _ := azure.CosmosPostgreSQL.CreateOrUpdateCluster(ctx, cpgdriver.CreateClusterConfig{
Name: "pg1", ResourceGroup: "rg1", Location: "eastus",
AdministratorLoginPassword: "s3cret!",
CoordinatorVCores: 4,
NodeCount: 2,
})
azure.CosmosPostgreSQL.CreateOrUpdateFirewallRule(ctx, cpgdriver.CreateFirewallRuleConfig{
ClusterName: "pg1", ResourceGroup: "rg1", Name: "office",
StartIPAddress: "10.0.0.0", EndIPAddress: "10.0.0.255",
})RestartCluster/StartCluster/StopCluster model the lifecycle actions; PromoteReadReplica detaches a replica from its source cluster.
Behavior & fidelity#
| Behavior | What happens |
|---|---|
| Clusters own children | A cluster is a coordinator plus worker nodes; its child resources cascade-delete with it. |
| Firewall rules | IP allow-list CRUD. |
| Roles | Postgres role CRUD. |
| Servers (nodes) | Read-only coordinator and worker nodes derived from the cluster shape. |
| Configurations | Cluster-wide and per-role server parameters. |
| Private endpoints | Connection CRUD and private-link resource reads. |
| Lifecycle actions | Clusters restart, stop, and start; a read replica links to a source cluster and detaches on promote. |
| LRO fidelity | Create/update return the resource inline with a terminal provisioningState; actions reply 202 + Location. |
SDK-compat — Live#
Real armcosmosforpostgresql clients drive it end-to-end (Microsoft.DBforPostgreSQL/serverGroupsv2) — see SDK-Compat for the full operation list.