Let's say you have your production environment deployed, and you want to create a staging environment. You have two options:
- Create a staging environment from scratch.
- Clone your production environment and create a staging environment from it.
This is where the Environment Clone feature of Qovery is useful. No need to create a new environment, just clone your production environment and create a staging environment from it.
In this guide, we will go through the steps to create a staging environment from your production environment. While applying the best practices by isolating the staging and production environments on two separated clusters and VPCs.
Before you begin, this page assumes the following:
- You already have a production environment deployed with Qovery.
Create a Staging cluster
Isolating the staging and production environments on two separate clusters and VPCs is a good practice to avoid any potential issues on your production caused by your staging. This is not a mandatory step, but it is well recommended.
To create your staging cluster it's also recommended creating a new AWS IAM access key and secret access key in a dedicated subaccount. Then you are sure that both environment are also isolated at the AWS level:
- Go to your Organization cluster settings
- Add a cluster with a name "staging"
- Deploy your staging cluster
Create your Staging environment from your Production environment
Now, to create your staging environment from your production environment, you need to:
- Go inside your production environment and click on the "Clone" button.
- Give a name to your staging environment (E.g "staging")
- Set the mode to "Staging"
- Set the cluster to "staging"
- Click on "Create"
- That's it!
Your environment has been created, but it's not deployed yet. Before we will make some adjustment to change the branch of our applications.
Update your Staging applications
Your Staging applications have the same branch as your Production applications. To update your Staging applications branch, you need to:
- Go into the settings of each of your applications.
- Update the branch to your Staging branch.
- Click on "Save"
We are almost done, now we need to smartly change our environment variables and secrets to not use the one used in production.
Override your environment variables and secrets
Let's say you have a production environment with the following environment variables:
- NODE_ENV=production
- STRIPE_API_KEY=a-secret-production-key
You might need to keep the same keys but change the values. That's exactly what Qovery makes you do with the Environment Variable Override feature. You can keep the same keys but change the values.
Deploy your Staging environment
Finally, your Staging environment has been created and set up correctly. To deploy your Staging environment, you just need to go to your Staging environment and click on the "Deploy" button.
Wrapping up
In this guide, we have covered everything you need to know to create a secure staging environment from your production. Now, you can take a look at how to seed your Staging database (Guide for Postgres but applicable for most databases).