Skip to main content

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.

OperationWhat it meansWhat you need to do
addA value is in the target but missing in the source.Add the value to the source.
replaceThe value exists in both, but they differ.Update the source to match the target.
removeThe value is in the source but not in the target.Remove it from the source.
moveA 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 for move operations. Specifies the original JSON Pointer of the value being moved
  • value: The new value to add or replace. Not present in remove or move 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.

What can be compared?

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:

np service compare create \
--id <target_service_id> \
--body '{"source_service_id": "<source_service_id>"}' \
--query .diff
Filter the response using the CLI

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.