Automating Infrastructure using AWS and Terraform

The Charotar University of Science and Technology did not stop worrying about their students development in midst of COVID-19 pandemic as they provide chance to their students to make project as a part of curriculum. As a part of it, I am able to complete my project in this pandemic situation to add it extra to resume.

You have questions like what’s the use of this project? Where it is helpful? What it does? What is the purpose behind this project? So basically, this project is all about automation of infrastructure hosted on AWS cloud platform. Infrastructure automation has became a daily need for company for easy deployment and maintenance of resources.

What is AWS?

What is Terraform?

What is CI/CD pipeline?

CI/CD Pipeline

Continuous Integration :

Continuous Delivery :

Continuous Delivery is a process where integrated code is pushed to specific environments. It ensures code delivery to specified infrastructure environment. It starts after continuous integration. CD ensures the automation of delivering new code with minimum efforts. Some extra checks are also performed during CD process such as performance test for production environment.

Continuous deployment :

Continuous Delivery vs Continuous Deployment

What is .NET?

There are various implementations of .NET. Each implementation allows .NET code to execute in different places — Linux, macOS, Windows, iOS, Android, and many more.

  1. .NET Framework is the original implementation of .NET. It supports running websites, services, desktop apps, and more on Windows.
  2. .NET Core is a cross-platform implementation for running websites, services, and console apps on Windows, Linux, and macOS. .NET Core is open source on GitHub.
  3. Xamarin/Mono is a .NET implementation for running apps on all the major mobile operating systems, including iOS and Android.

.NET Standard is a formal specification of the APIs that are common across .NET implementations. This allows the same code and libraries to run on different implementations.

Terraform Script :

provider “aws” {
region = “us-east-1”
access_key = “***”
secret_key = “***”
}

Create VPC:

resource “aws_vpc” “sgp” {
cidr_block = “10.0.0.0/16”
tags = {
Name = “SGP”
}
}

Create IGW:

resource “aws_internet_gateway” “gw” {
vpc_id = aws_vpc.sgp.id
}

Create public subnet:

resource “aws_subnet” “publicsubnet” {
vpc_id = aws_vpc.sgp.id
cidr_block = “10.0.1.0/24”
availability_zone = “us-east-1a”
tags = {
Name = “Public-subnet”
}
}

Create Private subnet:

resource “aws_subnet” “privatesubnet” {
vpc_id = aws_vpc.sgp.id
cidr_block = “10.0.2.0/24”
availability_zone = “us-east-1a”
tags = {
Name = “Private-subnet”
}
}
resource “aws_route_table” “public-route-table” {
vpc_id = aws_vpc.sgp.id
route {
cidr_block = “0.0.0.0/0”
gateway_id = aws_internet_gateway.gw.id
}
route {
ipv6_cidr_block = “::/0”
gateway_id = aws_internet_gateway.gw.id
}
tags = {
Name = “Public”
}
}

Create network interface:

resource “aws_network_interface” “sgp-nic” {
subnet_id = aws_subnet.privatesubnet.id
private_ips = [“10.0.2.50”]
security_groups = [aws_security_group.allow_web.id]
}

Create private route table:

resource “aws_route_table” “private-route-table” {
vpc_id = aws_vpc.sgp.id
route {
cidr_block = “10.0.2.0/24”
network_interface_id = aws_network_interface.sgp-nic.id

}
tags = {
Name = “Private”
}
}
tags = {
Name = “Private”
}
}

Associate subnet with route table:

resource “aws_route_table_association” “private” {
subnet_id = aws_subnet.privatesubnet.id
route_table_id = aws_route_table.private-route-table.id
}

Create Security group:

resource “aws_security_group” “allow_web” {
name = “allow_web_traffic”
description = “Allow Web inbound traffic”
vpc_id = aws_vpc.sgp.id
ingress {
description = “HTTPS”
from_port = 443
to_port = 443
protocol = “tcp”
cidr_blocks = [“0.0.0.0/0”]
}
ingress {
description = “HTTP”
from_port = 80
to_port = 80
protocol = “tcp”
cidr_blocks = [“0.0.0.0/0”]
}
ingress {
description = “SSH”
from_port = 22
to_port = 22
protocol = “tcp”
cidr_blocks = [“0.0.0.0/0”]
}
egress {
from_port = 0
to_port = 0
protocol = “-1”
cidr_blocks = [“0.0.0.0/0”]
}
tags = {
Name = “allow_web”
}
}

Create EC2 instance:

resource “aws_instance” “web-server-instance” {
ami = “ami-087c17d1fe0178315”
instance_type = “t2.micro”
availability_zone = “us-east-1a”
key_name = “sgp”
tags = {
Name = “web-server”
}
}

This is script for creating EC2 instance inside specific VPC with custom rules, routes and everything using Terraform.

Overview of Project :

Website using .NET framework

2x AWS Certified