Fork an Environment
A fork is a new environment seeded from an existing one in the same project. The fork records its parent, and each of its instances starts with the parent instance's params, version constraint, and release strategy. Every environment of a project has the same blueprint, so the project is the parity boundary.
Fork to get a copy of an environment that you can change on its own: staging from production, a developer's environment from staging, or a major version migration in isolation.
What a fork does​
forkEnvironment runs in one transaction:
- Creates the environment, linked to its parent.
- Creates one instance for each component in the project's blueprint.
- Copies each parent instance's params, except fields the bundle marks not
$md.copyable, with its version constraint and release strategy. - Copies environment defaults, secrets, and remote references when you ask for them.
Each copied environment default, remote reference, and secret passes the same checks as copyInstance. If one fails, the whole fork rolls back.
CLI​
mass environment fork <parent-environment> <new-ID> [flags]
parent-environmentis the full identifier of the parent, such asecomm-production.new-IDis the local part of the new identifier. It must match^[a-z0-9]{1,20}$. The full identifier is<project>-<new-ID>.
| Flag | |
|---|---|
--copy-environment-defaults | Copy the parent's environment defaults. |
--copy-secrets | Copy every instance's secrets from the parent, as mass instance copy --copy-secrets does for one instance. |
--copy-remote-references | Copy every instance's remote references from the parent. |
-n, --name | The name. Defaults to new-ID. |
-d, --description | The description. |
-a, --attributes | Custom attributes, such as -a region=us-east-1. |
Examples​
# Staging from production, with credentials
mass environment fork ecomm-production staging \
--copy-environment-defaults \
--copy-secrets
# A developer environment from staging, without secrets
mass environment fork ecomm-staging alicedev
# Reset staging to production's current state
mass environment fork ecomm-production staging --copy-environment-defaults

The fork appears in the project's environment list:

Fork again to reset​
Running forkEnvironment again with the same parent and new-ID runs the seed again:
- Params, version constraint, and release strategy reset to the parent's current values. Edits in the fork are lost.
- Environment defaults apply again.
- The
--copy-*flags of this call apply, so a second fork with--copy-secretsadds secrets that the first one left out.
A fork's parent cannot change. Forking with the same new-ID from a different parent fails.
What is not copied​
Without flags, a fork copies what copyInstance copies for one instance: copyable params, version constraint, and release strategy. For different secrets or remote references per instance, fork and then promote instance by instance.
When not to fork​
- A one-off change to an existing environment. Change the environment.
- Environments in lockstep. Forks diverge. Every environment of a project already has the same blueprint.
- Another project. A fork stays in its parent's project. Use
mass project cloneto copy a project.
Fork a sandbox for each developer​
The sandbox-on-join automation forks a template environment when a person joins a group, and removes the fork when they leave.
Reference​
mass environment forkforkEnvironmentin the V2 API- Projects and environments