This repository contains a basic web application demonstrating DevOps practices utilizing Infrastructure as Code (IaC) with Terraform.
![image](https://private-user-images.githubusercontent.com/33996820/292057284-e981b973-25fe-41a5-8025-a6149d27ca84.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE5MjAxNjMsIm5iZiI6MTcyMTkxOTg2MywicGF0aCI6Ii8zMzk5NjgyMC8yOTIwNTcyODQtZTk4MWI5NzMtMjVmZS00MWE1LTgwMjUtYTYxNDlkMjdjYTg0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI1VDE1MDQyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTUzODQ1MDM1ZDI3Y2JlOTZjM2E1NjkzNTY1OTMyY2FjNTA2Nzk3NDhiZDYzNjI3N2NlNzk3Yzc4NzAwYjEyZTgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.b_6NlM9kvpQRab6tO2_21zQlTW-pDvMZXK_shMXxM9o)
![image](https://private-user-images.githubusercontent.com/33996820/292057623-fba5c08c-145a-4f0e-addc-8844ac349a9e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE5MjAxNjMsIm5iZiI6MTcyMTkxOTg2MywicGF0aCI6Ii8zMzk5NjgyMC8yOTIwNTc2MjMtZmJhNWMwOGMtMTQ1YS00ZjBlLWFkZGMtODg0NGFjMzQ5YTllLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI1VDE1MDQyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM0OTk0NzYyYjI3ODU0YTFkMTAwNjJhNWVjNmU0YzE4ODNlMWU0MGY1M2UyZWM5ODM2NTdlNTc3YTM2OTdhMzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.TmW3kbN1VCj9Y28KoQxnseYkgxRLHEYQYlEKcRygP-Y)
The project aims to showcase essential Terraform commands to manage infrastructure effectively:
-
Initialization: Initializes Terraform project
terraform init
-
Validation: Check if the Terraform configuration is valid.
terraform validate
-
Planning: View the entire infrastructure plan before deployment.
terraform plan
-
Code Formatting: Keep your Terraform code consistent and formatted.
terraform fmt
-
Deployment: Deploy the infrastructure using Terraform.
terraform apply
Before running the terraform plan
or terraform apply
commands, make sure to authenticate with AWS:
export AWS_ACCESS_KEY_ID=<key id>
export AWS_SECRET_ACCESS_KEY=<secret>
Replace <key id>
and <secret>
with your AWS access key ID and secret access key. This ensures that Terraform has the necessary permissions to create and manage resources on AWS.
This Terraform project accomplishes the following:
- Infrastructure Deployed: Creates an ECS cluster with Fargate launch type.
- Containerized Application: Runs a Docker container with a simple web app Docker image from Amazon ECR.
- Load Balancer Configuration: Places the container behind a load balancer for traffic distribution.
For simplicity, the project is set up within the default Amazon VPC. However, it's strongly advised to configure and use your own VPC to implement specific security measures and network isolation best practices.
To get started with this project, follow these steps:
- Clone the repository.
- Ensure Terraform is installed on your machine.
- Set up AWS authentication as mentioned above.
- Run the commands mentioned in the Overview section to validate, plan, format, and deploy the infrastructure.
- Modify the Terraform configurations (
*.tf
) according to your infrastructure requirements. - Always review the Terraform plan before applying changes to your infrastructure.
- Ensure proper credentials and permissions are set for deploying infrastructure.