Design and create a highly available three-tier AWS architecture for web application and deploy using automation IAC Terraform with S3 Remote backend. User will access the application through the Internet, but the database mustn’t be accessible by the user.
Three-tier architecture that includes a presentation tier (user interface), logic tire(application), and data tier(database) is the most implemented in terms of high scalability, security, data integrity, and performance.
Terraform is one of the most popular open-source infrastructures as a code automation tool created by HashiCorp. It can manage infrastructure on multiple cloud platforms and supports human-readable configuration language, which helps write infrastructure code quickly and efficiently. Terraform's state allows tracking resource changes throughout your deployments.
Remote backends enable storage of TerraForm state in a remote, location to enable secure collaboration.
In this project I use AWS S3 + Dynamo DB for remote Backend
• VPC
• EC2 instances
• Elastic IP
• Baston Host
• Nat Gateway
• Load balancer
• Auto Scaling
• RDS instance
• Route 53 DNS Config
--> AWS Account
--> AWS Access & Secret Key
--> Terraform installed on IDE (i.e Visual Studio Code)
--> SSH Agent (For Windows), AWS Installed on Terminal (For Mac)
--> MySql Workbech for Database connection testing
Step 0 used to initialize a working directory containing Terraform configuration files
terraform init
Step 1 used to create an execution plan
terraform plan
Step 2 validates the configuration files in a directory, referring only to the configuration and not accessing any remote services such as remote state, provider APIs, etc
terraform validate
Step 3 used to apply the changes required to reach the desired state of the configuration Steps to initialize backend in AWS and manage it with Terraform:
terraform apply
backend "s3" {
bucket = "terraform-bucket" # s3 bucket name
key = "tf/terraform.tfstate" # state file location
region = "us-east-1"
dynamodb_table = "terraform-state-locking"
encrypt = true
}
terraform init
if Reinitialize failed
run bellow code
terraform init -backend-config="access_key=<your_AWS_access_key>" -backend-config="secret_key=<your_AWS_secret_key>" -backend-config="region=us-east-1"
On the AWS console, the following item should be available: VPC, subnets, IGW, EC2 instances, load balancers, autoscaling, RDS database, route 53, and S3 bucket with inside terraform state file