Skip to main content

Environments

Environments are made up of the content model, content, and media. Additionally, locales and UI extensions can be altered per environment. When making changes to any of the aforementioned entities in any environment, including master, the data in all other environments isn't affected and stays the same.

Think of Contentful environments more similar to a git branch rather then a production, development or local environment.

It is useful to call environments by a useful branch name, JIRA ticket number or to have a timestamp relating to when a snapshot was taken.

When working with environments and the Content Management API make sure that access tokens have the correct scope to access the given resource.

CI and Workflows

Environment merging and publihsing should work in the same way as a Git workflow - where environments are branched from the current master alias, updated and developed against and then re-assigned as master. See diagram below:

Contentful master-sandbox environments.

We can also incorperate this setup in to our QA testing by adding additonal correlating dev envrionments and contentful environments

Contentful QA environments.

Away from pre-defined environments we will be running feature branches which should be created, re-created or updated, and destroy via CI pipleines. These can act as limited time preview environments for features and content for the wider team and business before reaching production.

Aliasing

An environment alias allows you to access and modify the data of an environment, called the target environment, through a different static identifier.

Alias' are similar to git tags, and can be swapped in seconds as they do not require a complete environment build to occur. They are useful to have set names (i.e master, develop, preview) and can be tied to a development environment. We should aim to target alias' rather then specific environment.

Aliases empower you to quickly switch which environment is being served from these routes. Simply send a PUT request to re-target the master alias to a different environment. If something goes wrong and you need to roll it back, simply re-target master to any previous environment.

Contentful Aliasing.

Contentful Aliasing.

Useful Reading