Skip to main content

Promote Configs Across Environments

Massdriver promotes one instance at a time. mass instance copy, aliased promote, writes the configuration of one instance to another instance of the same component. Deploying the destination is a separate step.

shell
mass instance promote ecomm-staging-db --to ecomm-production-db

Promoting an instance config from the CLI

The source here is a PostgreSQL instance in a preview environment, on latest+dev with tuned params:

Source instance config in the preview env

The destination, in production, is still on v0.0.0:

Production instance before promote

After the promote, the destination has the source's params and version, ready to deploy:

Production instance after promote

What is copied​

  • The source's params, except fields the bundle marks $md.copyable: false
  • The source's version constraint and release strategy (stable or development)
Flag
--toRequired. The destination instance.
-o, --overridesA JSON or YAML file of params, deep-merged onto the source params before they are written. Use it for values that differ between environments, such as instance size or replica count.
--copy-secretsCopy the source's secret values. Needs instance:configure on the source.
--copy-remote-referencesCopy the source's remote references. Needs resource:view on each referenced resource, and a resource grant that shares it with the destination environment.

The copy runs in one transaction. If a step or a permission check fails, nothing is copied.

Without overrides, the destination gets the same configuration as the source.

Flow​

shell
# Copy staging's database config to production
mass instance promote ecomm-staging-db --to ecomm-production-db

# Or with production sizes
mass instance promote ecomm-staging-db --to ecomm-production-db \
--overrides ./prod-db.yaml

# Review the change with a plan, then deploy
mass instance deploy ecomm-production-db --plan
mass instance deploy ecomm-production-db

Components must match​

The source and destination must be instances of the same component. The API refuses any other copy.

In CI​

yaml
- name: Promote staging configs to production
if: github.ref == 'refs/heads/main'
run: |
mass instance promote ecomm-staging-db --to ecomm-production-db
mass instance promote ecomm-staging-app --to ecomm-production-app

A promote changes configuration only, so production does not change until someone deploys it. To require approval, give the CI service account instance:propose in production and deploy with --propose. Refer to Two ways to deploy a change.

Beyond two environments​

Any two instances of the same component work:

  • Regions: mass instance promote api-prod-uswest-db --to api-prod-useast-db
  • Tenants: mass instance promote api-template-cache --to api-acme-cache
  • Disaster recovery rehearsals: promote production into a parallel environment and deploy there.

Reference​