This repository contains Terraform code for deploying an AWS infrastructure environment as part of the BostonGene task.
- VPC with public and private subnets
- Application Load Balancer (ALB) connected to ECS instances
- ECS Cluster with tasks running the
http-echo
application - RDS PostgreSQL 17 instance for database services
- Corresponding Security Groups and IAM Roles for resource access control
Before applying this Terraform infrastructure, ensure you have the following:
- AWS Account with the necessary permissions to create resources.
- Terraform installed on your local machine.
- SSH Key Pair:
- Create an SSH key pair to use with the EC2 instances:
aws ec2 create-key-pair --key-name APP_NAME --query 'KeyMaterial' --output text > APP_NAME.pem chmod 400 APP_NAME.pem
- Ensure the private key file (
APP_NAME.pem
) is securely stored.
- Create an SSH key pair to use with the EC2 instances:
- Terraform Variables:
- All environment-specific values should be provided in the
terraform.tfvars
file. This file is not included in the repository and must be provided separately.
- All environment-specific values should be provided in the
Define your environment-specific values in terraform.tfvars
. Below is an example configuration:
environment = "dev"
region = "us-east-1"
instance_type = "t3.micro"
...
-
Clone the Repository:
git clone <repository_url> cd <repository_directory>
-
Initialize Terraform:
terraform init
-
Plan the Changes:
terraform plan
-
Apply the Configuration:
terraform apply
- Type
yes
to confirm when prompted.
- Type
-
Verify the Setup:
- Access the ALB DNS name (output from Terraform) to verify the web application.
- Use the RDS endpoint (output from Terraform) to validate database connectivity.
To destroy all resources and clean up the environment:
terraform destroy
Type yes
to confirm.
.
├── main.tf # root file
├── variables.tf # main variables file
├── outputs.tf # main outputs file
├── terraform.tfvars # environment variable values (not included in the repository)
├── modules/ # reusable modules directory
│ ├── ecs/
│ ├── iam/
│ ├── load_balancer/
│ ├── rds/
│ ├── security_groups/
│ └── vpc/
├── .gitignore # Git ignore file
└── README.md # Project documentation (this file)
After applying the configuration, the following outputs are available:
- ALB DNS Name: The URL of the Application Load Balancer.
- RDS Endpoint: The endpoint of the PostgreSQL database.