https://github.com/farhanshoukat/web-app-terraform
A simple web application deployed with terraform on AWS using a custom VPC and Autoscaling Group
https://github.com/farhanshoukat/web-app-terraform
automation aws cloud iac infrastructure-as-code terraform
Last synced: about 2 months ago
JSON representation
A simple web application deployed with terraform on AWS using a custom VPC and Autoscaling Group
- Host: GitHub
- URL: https://github.com/farhanshoukat/web-app-terraform
- Owner: FarhanShoukat
- License: mit
- Created: 2022-04-17T13:02:14.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-04-23T05:02:39.000Z (about 4 years ago)
- Last Synced: 2025-03-31T16:32:37.304Z (about 1 year ago)
- Topics: automation, aws, cloud, iac, infrastructure-as-code, terraform
- Language: HCL
- Homepage:
- Size: 957 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Web App Terraform
A simple web application deployed on AWS using Terraform. This project does not focus on creating a web application rather how to deploy it on AWS and autoscale it according to the traffic. For this purpose, EC2 instances are running in an Autoscaling Group. To expose the application to the world, an Application Load Balancer is attached to the Autoscaling group.
## Architecture
As it can be seen the EC2 instances (Web servers) are deployed in a private subnets to make sure they are not accessible publicly. The application is also deployed in two different Availability Zones for high availability.
## Prerequisites
AWS Command Line Interface (AWS CLI) and Terraform need to be installed and configured in order to run this application
* Follow [this](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) guide to install AWS CLI.
* Follow [this](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html) guide to configure AWS CLI.
* Follow [this](https://learn.hashicorp.com/tutorials/terraform/install-cli) guide to install Terraform.
## How to run
* Upload your zipped build archive to the S3 bucket. A sample hello world build archive is included [here](./project-archive.zip).
* Initialize Terraform project. This will download the required provider files.
```bash
terraform init
```
* Deploy the application
```bash
terraform apply
-var environment= # e.g. dev, staging, production
-var s3_bucket=
-var archive_path=
```
**Note:** You can find more variables like changing the minimum and maximum number of EC2 instances in [variables.tf](./variables.tf).
## Delete Provisioned Resources
Run the following command to destroy all the provisioned resources
```bash
terraform destroy
-var environment= # e.g. dev, staging, production
-var s3_bucket=
-var archive_path=
```
**Tip:** Instead of specifying all the variables in the terminal, they can also be placed in `terraform.tfvars` file.
## Contact
You can get in touch with me on LinkedIn: [Farhan Shoukat](https://www.linkedin.com/in/farhan-shoukat/)
## License
[MIT](./LICENSE) Copyright (c) 2022 Farhan Shoukat