Compare services across environments
Compare services across environments
You can compare two service instances to see exactly how they differ. This is especially useful when reviewing changes
across environments—like from development
to staging
, or between region-specific deployments.
A comparison returns a structured diff
using JSON Patch format.
You’ll see which attributes were added, removed, or changed—and where.
This is often the first step before deciding to sync or create a new service based on an existing one.
How this works
To compare two services, you select a source service and compare it against a target service. You can do this using the API or CLI.
The response includes a diff
, which is a list
of JSON Patches showing how the target differs from the source.
{
"diff": [
{
"op": "replace",
"path": "/dimensions/environment",
"value": "staging"
}
],
"source": {...}, // The source service instance
"target": {...} // The target service instance
}
Understanding the diff
output
Each item in the array represents a change that would make the source match the target.
Operation | What it means | What you need to do |
---|---|---|
add | A value is in the target but missing in the source. | Add the value to the source. |
replace | The value exists in both, but they differ. | Update the source to match the target. |
remove | The value is in the source but not in the target. | Remove it from the source. |
move | A value needs to be relocated. Includes a from path. | Move the value from one path to another in the source. |
Other fields:
path
: A JSON Pointer that tells you where the operation should happen in the source.from
: Required formove
operations. Specifies the original JSON Pointer of the value being movedvalue
: The new value toadd
orreplace
. Not present inremove
ormove
operations.
These operations aren’t applied automatically—they’re suggestions for how to align the two services. You can apply them manually or use them as part of your promotion process.
Only services with the same specification structure can be compared (for example, two SQS Queue services or two MySQL services).
Run a comparison
You can start a comparison using either the API or the CLI:
- CLI
- cURL
np service compare create \
--id <target_service_id> \
--body '{"source_service_id": "<source_service_id>"}' \
--query .diff
curl -L 'https://api.nullplatform.com/service/<target_service_id>/compare' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <token>' \
-d '{
"source_service_id": "<source_service_id>"
}'
Use the --query .diff
flag to return just the list of JSON Patches.
Use case: API Gateway service
Let’s say you manage an API Gateway service that defines endpoint paths. You can compare the service across environments to:
- Check if routing rules are consistent across environments
- Catch mismatches or missing endpoints
- Confidently promote accurate configurations
By running a service comparison, you can quickly surface these kinds of differences and take action before they cause issues.