Skip to content

Highly Available, Fault Tolerant, Three-Tier-Architecture on AWS provisioned via Terraform

License

Notifications You must be signed in to change notification settings

BJWRD/three-tier-architecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Three-Tier-Architecture

Architecture

This network architecture has three subnet tiers split across three availability zones. The web subnets also have a VPC routing table that will provide it access to the internet. The application and database tiers will not have such access; their routing tables will only allow internal network communication.

Prerequisites

  • An AWS Account with an IAM user capable of creating resources – AdminstratorAccess
  • A locally configured AWS profile for the above IAM user
  • Terraform installation - steps
  • AWS EC2 key pair - steps
  • Environment Variables for AWS CLI - steps
  • tfupdate installation - steps
  • tfsec installation - steps

How to Apply/Destroy

This section details the deployment and teardown of the three-tier-architecture. Warning: this will create AWS resources that costs money

Deployment Steps

1. Clone the repo

git clone https://github.com/BJWRD/three-tier-architecture && cd three-tier-architecture

2. Update the s3 bucket name to your own - versions.tf

backend "s3" {
  bucket = "ENTER HERE"
  key    = "terraform.tfstate"
  region = "eu-west-2"
}

3. Update versions.tf

tfupdate terraform versions.tf && tfupdate provider aws versions.tf

4. Access the relevant environment

cd dev

NOTE: The environment you choose is dependent on whether you plan to provision resources which are adequate for a dev/stage/prod environment.

5. Initialise the TF directory

terraform init

5. Ensure the terraform code is formatted and validated

terraform fmt && terraform validate

6. tfsec - vulnerability check

tfsec

7. Create an execution plan

terraform plan

8. Execute terraform configuration

terraform apply --auto-approve

image

Verification Steps

1. Check AWS Infrastructure

Check the infrastructure deployment status, by enter the following terraform command -

 terraform show

image

NOTE: You may want to ouput terraform show to a .txt file for easier viewing i.e. terraform show > tf_infrastructure.txt

Alternatively, log into the AWS Console and verify your AWS infrastructure deployment from there.

VPC Verification

image

EC2 Verification

image

RDS Verification

image

2. Verify bjwrd/app.py webapp is running via Docker

SSH onto one of the EC2 hosts and verify that the bjwrd/app.py docker container is running -

docker ps

image

Alternatively, you can retrieve the ALB DNS address and search within your browser.

Teardown Steps

1. Destroy the deployed AWS Infrastructure

terraform destroy --auto-approve

image

Requirements

Name Version
terraform ~>1.3.9
aws ~>3.50.0

Providers

Name Version
aws ~>3.50.0

Modules

Name Source
vpc three-tier-architecture/modules/vpc
ec2 three-tier-architecture/modules/ec2
rds three-tier-architecture/modules/rds

Resources

Name Type
aws_launch_template resource
aws_db_instance resource
aws_vpc resource
aws_subnet resource
aws_internet_gateway resource
aws_route_table resource
aws_route_table_association resource
aws_lb resource
aws_lb_listener resource
aws_lb_target_group resource
aws_autoscaling_group resource
aws_db_subnet_group resource
aws_security_group resource

About

Highly Available, Fault Tolerant, Three-Tier-Architecture on AWS provisioned via Terraform

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published