Our Blog

Using Terraform to setup web application on AWS - Part 1
AWS + Terraform - deployment

Using Terraform to setup web application on AWS - Part 1

Brief Introduction of AWS and Terraform

In this blog series, we will explore how to use Terraform to setup an infrastructure for running Web Application on AWS Cloud. This will be a multi-part series. This part will be an introductory in nature and we will review required AWS services and prerequisite software.

AWS (Amazon Web Services) is a comprehensive cloud computing platform provided by Amazon. It offers a wide range of on-demand services, including computing power, storage, databases, networking, machine learning, and more, enabling businesses and individuals to build and scale applications without the need for physical infrastructure.

Here's a brief overview of the key AWS services required:

1. EC2 (Elastic Compute Cloud): AWS EC2 provides scalable virtual servers (instances) in the cloud. It allows users to run applications, host websites, or perform computations by choosing instance types based on CPU, memory, and storage needs. EC2 supports various operating systems and allows custom configurations.

2. RDS (Relational Database Service):AWS RDS is a managed database service that supports popular relational database engines like MySQL, PostgreSQL, MariaDB, Oracle, and SQL Server. It simplifies database setup, scaling, patching, and backups, freeing users from the complexities of database management. We will use MySQL for development.

3. Load Balancer (Elastic Load Balancing)An AWS Load Balancer automatically distributes incoming traffic across multiple EC2 instances, containers, or IP addresses. It helps improve application availability and fault tolerance by ensuring no single instance is overwhelmed with traffic. AWS offers different types of load balancers, such as:

- Application Load Balancer (ALB) Optimized for HTTP/HTTPS traffic and advanced routing.

- Network Load Balancer (NLB) Handles TCP/UDP traffic at high performance.

- Gateway Load Balancer (GLB) Designed for third-party virtual appliances.

Terraform Developed by HashiCorp, Terraform is an open-source, declarative coding tool that allows for simple, effective handling of service infrastructure across a multitude of cloud platforms like AWS, Google Cloud, Azure, and others. Its expressive language makes it a preferable choice for codifying APIs into declarative configuration files.

Using Terraform, you can set up your AWS Infrastructure for a web application in an efficient manner. By defining your infrastructure setup in code, you allow for transparent, reproducible, and version-controllable infrastructure management. This contributes to reducing the "unknowns" in the system and fostering a smooth, error-free deployment pipeline. For a DevOps team, this means faster issue resolution, reduced downtimes, and a more streamlined software delivery.

Proposed Architecture for Web Application

For developing a secure and scalable web application on AWS, we incorporate key AWS services - Amazon EC2 for hosting the application, and Amazon RDS for backend database management.

To ensure stringent security measures, the EC2 setup is structured to reside in private subnets, with public access routed through an Application Load Balancer (ALB) using AWS-provided SSL certificates to secure communication. The RDS setup is deliberately restricted to be private to maintain data integrity. For end-to-end secure and private communication, the design incorporates setting up requisite security groups, virtual subnets, and virtual private clouds (VPC).

Proposed Architecture

Prerequisite Software Installation

In order to create the infrastructure using Terraform, we will need to install the following software:

AWS CLI : When it comes to managing AWS services efficiently, AWS Command Line Interface (CLI) is your companion. Precisely, these are the tools that let you control multiple AWS services directly from the terminal or command prompt, which is pretty useful for scripting. To securely access your AWS account, you'll have to use it to set AWS credentials on your local system

On Ubuntu 22.04, we can use snap to install AWSCLI using the following command: snap install aws-cli --classic snap install aws-cli --classic Now we can setup AWS credentials by running aws-cli on the command line as follows: aws configure This will start a commandline wizard. Please follow the wizard in order to setup AWS Credentials on your local machine / server. Run aws configure We can verify successful installation using the following command: aws --version Run aws --version

Terraform: Terraform is an open-source program developed by HashiCorp. Please follow these instructions in order to install Terraform on Ubuntu 22.04:

First of all, update your system. sudo apt update -y Run sudo apt update Install the necessary software for adding repositories and managing packages: sudo apt install -y gnupg software-properties-common curl Install necessary libraries Add the official HashiCorp GPG key to verify package authenticity: curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg Add HashiCorp GPG key Add the HashiCorp package repository to your system: echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list Add HashiCorp Repository Update the package list to include the HashiCorp repository: sudo apt update Update Package list Now install the Terraform using the following command: sudo apt install -y terraform Install Terraform Cli Check the installed version of Terraform: terraform -version Verify Terraform Cli Installation

Executive Summary

In part 1 of this series, we've covered a basic introduction to AWS and the required services, installation of prerequisite software and high-level architecture for the web application.

In the forthcoming series, as we dive more into creating AWS resources, managing them through Terraform (by writing your first `main.tf`), planning and applying Terraform configurations, you will get the hands-on experience you need to create a scalable and flexible infrastructure for your web applications with Terraform on AWS.

Our solutions for your business growth

Our services enable clients to grow their business by providing customized technical solutions that improve infrastructure, streamline software development, and enhance project management.

Our technical consultancy and project management services ensure successful project outcomes by reviewing project requirements, gathering business requirements, designing solutions, and managing project plans with resource augmentation for business analyst and project management roles.

Read More
2
Infrastructure / DevOps
3
Project Management
4
Technical Consulting