How I created a multi-cloud distributed solution with AWS and Azure free tier

Jaime Dantas
Feb 2, 2020 · 9 min read
Photo by Jaime Dantas — Fortaleza — Brazil

In this post, I’ll describe step-by-step how I built an entire distributed solution using only AWS and Azure free tier products. The services I created were scattered throughout both these cloud providers, and they are up and running in production mode 24/7 at this moment. These services were coded in Java and Angular. By the end of this post, you’ll know how to host your own applications in the cloud without spending a penny.

Overview

Overall, this project is composed of 5 services in total:

  • fiiz-tax-frontend: Static website in HTML 5 hosted on GitPages
  • fiiz-tax-ui: Angular 8 application GUI
  • fiiz-tax-authenticator: Spring Boot microservice for authentication and storage
  • fiiz-tax-calculator: Spring Boot microservice for math operations
  • fiiz-tax-database: MySQL database

All these services were created from the ground up and launched into production using only free tiers offered by cloud providers. The GitHub Pages service was also used for hosting the website of this solution. You heard that right, I was able to put on the market a complete business with zero cost.

I’ll use the C4 model for describing the architecture of this project through diagrams and components. If you don’t know what that is, feel free to check the documentation here.

The architecture of this project is shown below.

Container diagram

Below I’ll deep dive into each of these components, and explain how I built my cloud.

Solution

www.fiiztax.com

I’ve decided to create a service called FIIZ TAX which consists of an automated tool for calculating transaction taxes in the Brazilian stock exchange B3. In order to do its prototype, I used the free tiers of AWS and Azure for hosting my services.

All services are up and running 24/7 now, and you can check them out by clicking here.

Website

www.fiiztax.com

The first thing I created was the service’s landing page. Nowadays, building a static webpage is a piece of cake. With so many HTML templates available for free on the Internet, the hard part here was deciding where to host my website. I thought about putting it on a cloud provider, but then I went for the GitHub pages. GitHub Pages is a free and easy way to host your own website as long as they are in a public repository.

This website serves as an entry door for our actual User Interface (UI). The user must click a redirect button to be able to log in and use the Angular frontend.

This is my public repository on GitHub:

Buying a domain

Frontend

Technologies:

  • Angular 8.2.14
  • Bootstrap 4.3.1
  • Angular CLI: 8.3.22
  • Node: 10.13.0

Microservices

fiiz-tax-authenticator

I am using Spring Security combined with JSON Web Token (JWT) for securing my application. The article below does an awesome job explaining this concept, so I won’t go further in details about this technology.

This service will also perform reading and writing operations in our database which will be explained in a bit.

Technologies:

  • Spring Boot 2.2.2
  • JJWT 0.9.1
  • Spring Boot Security
  • Spring Boot Data JPA

fiiz-tax-calculator

Since there is no need to expose these endpoints directly to the internet, the security system used here was based on security token, and it is managed by the fiiz-tax-authenticator.

If you want to know more about its concept, I have a similar microservice available on my GitHub:

One of the dependencies I use was the Swagger interface. This library is used for generating the documentation of Spring Boot services, and it has a UI interface where we can send requests to the APIs with ready-to-use input data.

Technologies:

  • Spring Boot 2.2.2
  • Springfox Swagger 2.9.2

Database

Architecture

AWS

As soon as I logged in on my AWS Console, I created a security group for my services. In this security group, I opened the port 443 for HTTPS and 22 for SSL to allow inbound access.

It’s important to set it up a budget limit for your account so you don’t have any unwanted surprises when your credit card bill arrives. In my case, I created a USD 10 limit for using AWS services.

EC2

As soon as you get your EC2 ready, you’ll need to install all the required software to get your services running. In my case, I had to install Angular, node.js, maven, JDK, Nginx, and Git.

After starting both my services in this instance, I noticed that1 GB RAM is not enough memory to keep them running smoothly. However, they work just fine as long as they are under a low load. With this configuration, I am using almost all the RAM.

AWS EC2 running Angular and Java service

Update: I migrated the fiiz-tax-ui service to the Firebase! I’ve documented the whole thing here:

SSL Certificate

Since I didn’t want to spend money on this project just yet, I’ve decided to use the Letsencrypt SSL service to get my free certificate. The process is quite simple, and it doesn’t require many steps at all. Below you can find the tutorial to get yours installed on your EC2 instance as well.

Nginx

cd /etc/nginx/sites-available
sudo nano default

Now you’ll need to add all the routes you have. In my case, I’m running two services, and I want that all the routes but the /tax/ and /auth/ redirect to port 4200 where our UI is running.

location / {
proxy_pass http://localhost:4200;
}
location /tax/ {
proxy_pass http://localhost:8081;
}
location /auth/ {
proxy_pass http://localhost:8081;
}

Finally, your EC2 instance should be ready for the next step.

RDS

After creating your RDS instance, it’s time to point your EC2 microservice to your RDS database. I also run some SQL scrips for creating my schema and tables from the EC2 instance using the MySQL Client. You can either connect to your RDS server from your computer using any database management software or install the MySQL client on your EC2 instance as shown below.

apt-get install mysql-client

Now your entire ecosystem is almost ready. This should be enough to get your service online if you’re using only AWS.

Azure

VM

I only opened port 80 for HTTP traffic, and the authorization token is used for securing my application. I am using also using Ubuntu 18.04 OS on my VM instance. Since I am only running a Java microservice, the dependencies I installed were JDK, maven, and Git.

Azure / AWS communication

Conclusion

I hope the article helped you to understand how AWS and Azure free tier works, and how to create your own services and make them online all over the internet for free.

If you have any questions, don’t hesitate in reaching me for further clarification.

Thanks for reading it!

www.jaimedantas.com

Reverse Engineering

Ideas, concepts, tutorials, and tips about the computer…

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store