Learn what are environments and how they work in a Webiny project.
- what are environments
- how are environments handled in a Webiny project
What Are Environments?
Your project can be deployed into multiple environments.
This means that you can have multiple “copies” of your project up and running at the same time, each having its own name and purpose.
Every project most certainly has an environment called production. This is the environment that represents “the real thing” - the system that’s being used by real users. It’s in your best interest to ensure this system is always online and the code that makes it into this environment is well tested. In order to achieve this, you deploy your project to a number of pre-production environments.
For example, you might have multiple development environments, to which developers can deploy their changes, ready to be tested by the rest of the team. Once the changes have been approved, an additional round of testing can be done in a preview, or more commonly called, staging environment. This is the environment that’s the closest to the production environment in terms of the code, different configurations, cloud infrastructure, and so on.
Environments in a Webiny Project
Every project application can be deployed into several different environments. For example, we might have three applications in our project, and for each, we might want to have three different environments: dev, staging, and production.
Note that Webiny does not sync environments across your project applications. Meaning, if you want to deploy your entire project into a specific environment, you need to deploy every application into it. So, in the case of the above project, you would need to deploy all three applications.Fortunately, Webiny makes it easy to work with different environments, using the Webiny CLI and Pulumi. Be sure to check out the Deploy your project guide to learn how to deploy a Webiny project.
How Many Different Environments Can a Project Have?
The answer is: as many as needed. There is no limit on the count of different environments you can deploy.
Depending on the Environment, Can a Different Cloud Infrastructure Be Deployed?
This can be done. Since the cloud infrastructure is defined using code, nothing prevents you from using a couple of
if statements to determine which resources need to be deployed.
Is It Reasonable to Have Different Cloud Infrastructure Deployed Based on the Environment?
In certain cases, this might be reasonable. For example, you can reduce development costs by not deploying custom VPCs (and related cloud infrastructure resources) for development environments. You only deploy the full set of cloud infrastructure resources into staging and production environments.