{"id":22016199,"url":"https://github.com/bjwrd/three-tier-architecture","last_synced_at":"2025-05-07T01:22:25.417Z","repository":{"id":153295851,"uuid":"392301059","full_name":"BJWRD/three-tier-architecture","owner":"BJWRD","description":"Highly Available, Fault Tolerant, Three-Tier-Architecture on AWS provisioned via Terraform","archived":false,"fork":false,"pushed_at":"2023-02-17T10:27:16.000Z","size":58,"stargazers_count":12,"open_issues_count":0,"forks_count":14,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T04:51:36.872Z","etag":null,"topics":["aws","fault-tolerant","highly-available","terraform","terraform-aws"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BJWRD.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-03T11:56:44.000Z","updated_at":"2024-07-25T03:15:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"adad3540-a117-45cb-ba0e-d53b7dde455e","html_url":"https://github.com/BJWRD/three-tier-architecture","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BJWRD%2Fthree-tier-architecture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BJWRD%2Fthree-tier-architecture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BJWRD%2Fthree-tier-architecture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BJWRD%2Fthree-tier-architecture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BJWRD","download_url":"https://codeload.github.com/BJWRD/three-tier-architecture/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252794293,"owners_count":21805174,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","fault-tolerant","highly-available","terraform","terraform-aws"],"created_at":"2024-11-30T04:33:24.281Z","updated_at":"2025-05-07T01:22:25.411Z","avatar_url":"https://github.com/BJWRD.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Three-Tier-Architecture\n\n# Architecture\nThis 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.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/83971386/127896132-06db5721-51ec-4c5f-81ee-6e39d14fa803.png\" width=\"90%\"\u003e\u003c/img\u003e\n# Prerequisites\n* An AWS Account with an IAM user capable of creating resources – `AdminstratorAccess`\n* A locally configured AWS profile for the above IAM user\n* Terraform installation - [steps](https://learn.hashicorp.com/tutorials/terraform/install-cli)\n* AWS EC2 key pair - [steps](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html)\n* Environment Variables for AWS CLI - [steps](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html)\n* tfupdate installation - [steps](https://github.com/antonbabenko/pre-commit-terraform#how-to-install)\n* tfsec installation - [steps](https://github.com/antonbabenko/pre-commit-terraform#how-to-install)\n\n# How to Apply/Destroy\nThis section details the deployment and teardown of the three-tier-architecture. **Warning: this will create AWS resources that costs money**\n\n## Deployment Steps\n\n#### 1.\tClone the repo\n    git clone https://github.com/BJWRD/three-tier-architecture \u0026\u0026 cd three-tier-architecture\n    \n#### 2. Update the s3 bucket name to your own - `versions.tf`\n\n    backend \"s3\" {\n      bucket = \"ENTER HERE\"\n      key    = \"terraform.tfstate\"\n      region = \"eu-west-2\"\n    }\n    \n\n#### 3. Update `versions.tf`\n    tfupdate terraform versions.tf \u0026\u0026 tfupdate provider aws versions.tf\n    \n#### 4. Access the relevant environment \n    cd dev\n    \n**NOTE:** The environment you choose is dependent on whether you plan to provision resources which are adequate for a `dev/stage/prod` environment.\n\n#### 5.\tInitialise the TF directory\n    terraform init\n\n#### 5. Ensure the terraform code is formatted and validated \n    terraform fmt \u0026\u0026 terraform validate\n\n#### 6. `tfsec` - vulnerability check\n    tfsec\n    \n#### 7. Create an execution plan\n    terraform plan\n\n#### 8. Execute terraform configuration \n    terraform apply --auto-approve\n    \n\u003cimg width=\"348\" alt=\"image\" src=\"https://user-images.githubusercontent.com/83971386/218799991-3bd9f750-5984-496a-9c11-2f145622339d.png\"\u003e\n\n\n## Verification Steps \n\n#### 1. Check AWS Infrastructure\nCheck the infrastructure deployment status, by enter the following terraform command -\n\n     terraform show\n\n\u003cimg width=\"426\" alt=\"image\" src=\"https://user-images.githubusercontent.com/83971386/218800177-9b4fde90-80ca-41ab-aa20-d8a199e104a3.png\"\u003e\n\n**NOTE:** You may want to ouput `terraform show` to a .txt file for easier viewing i.e. terraform show \u003e tf_infrastructure.txt\n\nAlternatively, log into the AWS Console and verify your AWS infrastructure deployment from there.\n\n#### VPC Verification\n\n\u003cimg width=\"673\" alt=\"image\" src=\"https://user-images.githubusercontent.com/83971386/218800769-18a359e8-78d9-45d7-bdaf-f1a96226a7eb.png\"\u003e\n\n#### EC2 Verification\n\n\u003cimg width=\"653\" alt=\"image\" src=\"https://user-images.githubusercontent.com/83971386/219601104-31139fe9-2f47-4ad8-8607-77c72126bbe1.png\"\u003e\n\n####  RDS Verification\n\n\u003cimg width=\"652\" alt=\"image\" src=\"https://user-images.githubusercontent.com/83971386/218801322-bd18927c-e7de-4aa9-bf96-7aa460f13f67.png\"\u003e\n\n#### 2. Verify bjwrd/app.py webapp is running via Docker \nSSH onto one of the EC2 hosts and verify that the bjwrd/app.py docker container is running -\n\n    docker ps\n    \n\u003cimg width=\"513\" alt=\"image\" src=\"https://user-images.githubusercontent.com/83971386/219605219-28d1478f-ebcd-4cc5-af4e-5693aea96725.png\"\u003e\n\nAlternatively, you can retrieve the ALB DNS address and search within your browser.\n\n## Teardown Steps\n\n####  1. Destroy the deployed AWS Infrastructure \n`terraform destroy --auto-approve`\n\n\u003cimg width=\"381\" alt=\"image\" src=\"https://user-images.githubusercontent.com/83971386/219432782-46a8ae1c-6f03-4a7f-89bd-7dac1f79d23e.png\"\u003e\n\n## Requirements\n| Name          | Version       |\n| ------------- |:-------------:|\n| terraform     | ~\u003e1.3.9       |\n| aws           | ~\u003e3.50.0      |\n\n## Providers\n| Name          | Version       |\n| ------------- |:-------------:|\n| aws           | ~\u003e3.50.0      |\n\n## Modules\n| Name | Source |\n|------|--------|\n| \u003ca name=\"module_vpc\"\u003e\u003c/a\u003e [vpc](#module\\_vpc) | three-tier-architecture/modules/vpc |\n| \u003ca name=\"module_ec2\"\u003e\u003c/a\u003e [ec2](#module\\_ec2) | three-tier-architecture/modules/ec2 |\n| \u003ca name=\"module_rds\"\u003e\u003c/a\u003e [rds](#module\\_rds) | three-tier-architecture/modules/rds |\n\n## Resources\n| Name          | Type       |\n| ------------- |:-------------:|\n| [aws_launch_template](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/aws_launch_template) | resource |\n| [aws_db_instance](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/aws_db_instance) | resource |\n| [aws_vpc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/aws_vpc) | resource |\n| [aws_subnet](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/aws_subnet) | resource |\n| [aws_internet_gateway](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/aws_internet_gateway) | resource |\n| [aws_route_table](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/aws_route_table) | resource |\n| [aws_route_table_association](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/aws_route_table_association) | resource |\n| [aws_lb](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/aws_lb) | resource |\n| [aws_lb_listener](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/aws_lb_listener) | resource |\n| [aws_lb_target_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/aws_lb_target_group) | resource |\n| [aws_autoscaling_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/aws_autoscaling_group) | resource |\n| [aws_db_subnet_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/aws_db_subnet_group) | resource |\n| [aws_security_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/aws_security_group) | resource |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjwrd%2Fthree-tier-architecture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbjwrd%2Fthree-tier-architecture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjwrd%2Fthree-tier-architecture/lists"}