8000 GitHub - sudo-justinwilson/three-tier-web-app: An example 3-tier web application built with Terraform in AWS
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

sudo-justinwilson/three-tier-web-app

Repository files navigation

Three-tier Web Application

three tier web app

Getting Started

This builds the infrastructure for a three-tier web application in AWS.

The following components are built:

  • A VPC with a public subnet and 2 private subnets.
  • An ECS cluster with autoscaling in the middle private subnet.
  • An RDS DB instance in the bottom private subnet with scalable storage.
  • A reverse web proxy container in front of a web application container in ECS with the ability to scale.
  • An public facing application load-balancer in front of the reverse proxy.

Prerequisites

  • There is an assumption that AWS credentials are available.

Deployment

Use the following steps to deploy the stack.

  1. Clone this repository
git clone https://github.com/sudo-justinwilson/three-tier-web-app.git
  1. Change to the repo directory:
cd ${/PATH/TO/REPO}
  1. Install Terraform by following instructions here

  2. Once Terraform is installed and the terraform command is available, run the following commands to build the environment

$ terraform init
$ terraform plan
$ terraform apply     

Note:

  • This infrastructure is built in the ap-southeast-2 region by default. To change the region, edit the ./variables.tf.
  • I have encountered an error which prevents the downloading of the terraform-aws-modules/vpc/aws Terraform module. This error was fixed by upgrading to Terraform version 0.12.19. See this bug for more details.
  1. terraform apply will return multiple outputs, including an alb_dns_name output, which is the DNS record that points to the application load-balancer. Point your browser at the DNS record to see the web application.

Updating the Nginx configuration

The reverse web proxy is an Nginx Docker container. The nginx configuration is stored here on Github. Any pushes to this repository trigger a new build a new container version here in Docker Hub, making a new container image available.

We can then deploy the ECS service revision with the following aws command (assumes awscli is installed) to deploy the new image to the ECS cluster:

$ aws ecs update-service --cluster arn:aws:ecs:ap-southeast-2:853057580641:cluster/three-tier_ecs_cluster --service arn:aws:ecs:ap-southeast-2:853057580641:service/three-tier-service --force-new-deployment
  • Replace the --service value with the ecs_service_arn output value

Modules

Each directory in the 'modules/' directory is a Terraform module, that can be reused in other projects.

  • ecs-cluster
  • db (RDS)
  • alb
  • service (The Docker containers)

Tearing down the test environment

Once we're done testing, we can tear-down the environment with the following command:

$ terraform destroy

Built With

  • Terraform - Used to automate the building of infrastructure
  • Docker - Application containerization.
  • Nginx - Reverse web proxy.

Contributing

Submit bugs & feature requests via Github

Authors

  • Justin Wilson - Initial work - Github

License

This project is licensed under the GPL3.0 License - see the LICENSE.md file for details

About

An example 3-tier web application built with Terraform in AWS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0