5 Simple Steps to Create Preview Environments on AWS with Qovery
The process of software development has changed radically. Development is fast-paced and needs testing and staging environments to reflect production accurately. Still, achieving this can be a significant operational hassle. Most engineering teams use a single staging environment, making it hard for developers to test their changes in isolation.
That’s where Qovery’s Preview Environments comes in, solving this problem by automatically creating a clone of your production environment (including applications, databases and configuration) on every pull request, so you can test your changes confidently without affecting your production.
We have built the dream feature for any team of developers, and I will walk you through exactly how to implement and create Preview Environments on AWS with Qovery in 5 simple steps.
Albane TonnellierJune 16, 2022 · 4 min read
Albane is a Product Owner at Qovery with previous RoR developer experience.See all articles
Key advantages of using Qovery Preview Environments
Before diving into details and explaining how to use the preview environments on Qovery, let’s talk through some of the main reasons engineering teams use Preview Environments. Let me unpack the three big reasons:
Increased efficiency of DevOps
Replicating a production environment containing complex configuration, infrastructure components like load balancers, Kubernetes cluster, firewall, etc., takes a considerable amount of time and can lead to errors. Also, while staging is a replica of production, still, data, infrastructure, and configuration will be slightly different. Having the ability to automate environments by using the Preview Environments can give your distributed teams the ability to spin up and decommission the environments as needed, accelerating time to market.
Increased development speed
Preview Environments improve your overall development speed. As you can quickly spin up new environments for each pull request, testing can be performed in isolation without interfering with other environments, and can quickly roll out your releases.
First, you will save valuable time spent on the manual setup of the environment. Then, Qovery keeps your preview environments up to date on every commit and automatically destroys them when the original pull request is merged or closed. You can also set up an expiry time to automatically clean up preview environments after a period of inactivity. That way, you can achieve not only scalability but improved cost control.
If you want to know more about the best use cases for Preview Environments, here is a great article for you!
5 easy steps to create preview environments on Qovery
Managing Preview Environments has never been that simple! Before we dive in, let’s assume the following:
- You have sign in on Qovery
- You have installed Qovery on your AWS account
- You have at least already deployed successfully a first application
If all of those are done, let’s begin:
Step 1: Create a “Blueprint” environment
Even if not required, we recommend creating an environment that will serve as a root to create your Preview Environments. The idea is to keep this environment as a template of a fully working environment. This environment should not be directly used. This is what we call a "blueprint environment". To see how it works on the console, head to this tutorial.
Step 2: Enable Deployment Environment feature
Now, you can go to turn on Preview Environments in three simple steps:
- Click on your Blueprint environment "Settings".
- Click on the Preview Env. tab
- Turn on the Preview Environment feature for all your applications by clicking on Activate preview environment for all apps.
Now that you have turned on the Preview Environment feature, you need to change the base branch from your applications inside your Blueprint Environment. Let's say, every new feature branch you create are coming from staging. Then you will need to change all your applications to target the staging branch, to see how it’s done, here is a video explaining you everything.
Here is a flow example showing what happens when you create a new Pull Request from a feat/xxx branch that has been created from the base branch staging.
Step 3: Validate your Blueprint Environment
Before creating a Preview Environment, ensure your blueprint is ready by deploying it. Once the deployment is done and all the light green, you know everything is running smoothly. You can then stop it immediately and stop the auto-deploy inside the deployment settings so that when you push something on the staging branch or any other branch used by the Blueprint environment, this environment won’t be triggered.
Step 4: Create a Preview Environment
To create a Preview Environment, the steps are very easy as Qovery take care of cloning all your services and the configuration as well (Environment Variables and Secrets included), everything is done in three simple steps:
- Checkout your staging branch.
- Create a branch test_qovery_preview_environment and push it.
- Create a Pull Request/Merge Request.
You must see a new environment appearing in your environment list on Qovery. Wait until it is fully deployed, then you will be able to connect to it. This environment is fully isolated from your base environment.****
If you want to watch it in action, here is the video tutorial made for you.
Step 5: Delete a Preview Environment
To delete you need to merge the Preview Environment branch you created into staging. You also have the ability to delete it manually on Qovery.
If you want to see how it’s done in two minutes, here is a small video tutorial 👇🏻
To illustrate the environment flow; we made this schema to help you understand what is going on when you use the preview environment feature with Qovery
Eager to know how to go integrate Qovery Preview Environments with your CI and much more? We have an Advanced Preview Environment guide coming soon. In this advanced guide we will cover a wide range of topics such as “Auto-stop and start your Preview Environment”, “Seed your Preview Environment database”, “Integrate your CI (Continuous Integration) platform” and much more, and if you feel like preview environment is the feature you need, try it now!
Deploy your apps in production on AWS in minutes
Qovery combines the power of Kubernetes, the reliability of AWS, and the simplicity of Heroku to deploy your apps on AWS.Deploy my apps