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.
- 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
This section details the deployment and teardown of the three-tier-architecture. Warning: this will create AWS resources that costs money
git clone https://github.com/BJWRD/three-tier-architecture && cd three-tier-architecture
backend "s3" {
bucket = "ENTER HERE"
key = "terraform.tfstate"
region = "eu-west-2"
}
tfupdate terraform versions.tf && tfupdate provider aws versions.tf
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.
terraform init
terraform fmt && terraform validate
tfsec
terraform plan
terraform apply --auto-approve
Check the infrastructure deployment status, by enter the following terraform command -
terraform show
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.
SSH onto one of the EC2 hosts and verify that the bjwrd/app.py docker container is running -
docker ps
Alternatively, you can retrieve the ALB DNS address and search within your browser.
terraform destroy --auto-approve
Name | Version |
---|---|
terraform | ~>1.3.9 |
aws | ~>3.50.0 |
Name | Version |
---|---|
aws | ~>3.50.0 |
Name | Source |
---|---|
vpc | three-tier-architecture/modules/vpc |
ec2 | three-tier-architecture/modules/ec2 |
rds | three-tier-architecture/modules/rds |
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 |