The Simplest Way to Deploy Spring Boot with PostgreSQL on AWS
AWS (Amazon Web Services) is an amazing and reliable cloud service provider. AWS, like Google Cloud Platform and Microsoft Azure, provides everything you need to host an application without having to worry about running the underlying servers and network configuration. Everything you need to quickly begin hosting is provided as a packaged services.
However, deploying an application on AWS presents some challenges. The typical deployment workflow looks like this: write code, push it to Git, compile code, deploy code, validate your changes and repeat. Developers thus not only have to do all of this manually, but they also have to configure tons of services (VPC, database, cache, DNS, CDN, etc.) to make their application live on the web.
Qovery was created to solve this problem. In this blog post, I will show you how Qovery improves the developer experience to deploy staging and production Spring Boot application with PostgreSQL database on AWS. You will be able to focus on writing the best code instead of managing complex services.
- Operating system: MacOS / Windows / Linux
- A Github account
Optional: Get the Spring Boot sample application
Get a local copy of the Spring Boot sample project by forking the project using your Github account and by executing the following command:
The Qovery CLI is an open-source project that lets you deploy your applications directly on AWS, while taking advantage of well-known local tooling. We will use this tool to speed up our development cycle instead of using the typical development workflow (based on a CI/CD, Docker and other DevOps tools).
Install the Qovery CLI by running the following command:
Authenticate yourself before using it
Step 2: Deploy the Spring Boot application on AWS
To deploy the Spring Boot application connected to a PostgreSQL database, you need to have a .qovery.yml file and a Dockerfile (already provided) at the root of your project. This file indicate the external resources (eg. PostgreSQL) that your application need to work properly.
Optional (but recommended): Qovery provides a Java client to simplify the way to retrieve the PostgreSQL instance host, port, username and password.
To create the .qovery.yml file, run the following command:
The .qovery.yml file is created at the root of the project directory
Note: Qovery supports multiple databases (eg. PostgreSQL, MySQL, MongoDB, Redis, Memcached, Cassandra), brokers (eg. RabbitMQ, Kafka) and storage services(eg. S3).
Authorize the Qovery Github application to get access to your Github account through this link. After that, you just need to commit and push the .qovery.yml file in order to deploy your app.
Voila! Qovery is now deploying your app!
⚠️ BETA: During the Beta phase, the first deployment requires 26 minutes (the database requires a longer processing time while being deployed for the first time due to AWS). After that, each update will take only 2 minutes. Wait a couple of minutes and type the following command to get your application endpoint:
Bonus 1: Test the Spring Boot application locally
The Qovery motto is: if your application runs locally, then your application will run on Qovery. To test if your application is running locally, execute the following command:
Warning: Docker runtime required.
Navigate to http://localhost:8080 through your web browser and you should see a JSON response
Bonus 2: Deploy the application on a staging environment
Qovery has a very powerful feature known as “environment”. Qovery supports the deployment of isolated development environments from your branches, complete with exact copies of all of your data. This is useful for testing changes in isolation before merging them.
So, do you want to create a new feature, fix a bug or make a modification without impacting the production or any other important environment? Type the following commands:
Do your changes if required, and commit + push them
Qovery and AWS together bring to developers the full power of simplicity and flexibility while deploying applications. Any developer can now take advantage of AWS in seconds instead of days.