This Terraform project was created to deploy an infrastructure of three-tier components. The infrastructure is secured by a Bastion host that is used for the SSH connection and connects with the other 2 tiers of the application, and we use an autoscaling group to maintain the scalability and redundancy of the components, on the other hand, we use a load balancer to guarantee the connection of the frontend through the internet.
- AWS Account
- Proper Permissions for your user
- Terraform installed on your IDE
- AWS CLI installed and configured on your IDE
- SSH Agent (For Windows PowerShell)
Run command:
aws configure
AWS Access Key ID [None]: access key
AWS Secret Access Key [None]: secret access key
Default region name [None]: region
Default output format [None]: default output format
aws ec2 create-key-pair --key-name Three-Tier-Deployment --query 'KeyMaterial' --output text > Three-Tier-Deployment.pem
- Create a folder for the repository
- Navigate to the project directory
- Clone the repository:
git clone https://github.com/alejog38/AWSThreeTierApp.git
- Initialize terraform
terraform init
- Edit the terraform.tfvars file with your desired values, on the other hand, if you want to personalize the deployment you can check the variables.tf file.
- Verification of the configuration
terraform plan -var-file=terraform.tfvars
- Deploy
terraform apply -var-file=terraform.tfvars
- Destroy
terraform destroy -var-file=terraform.tfvars
Command to connect to the Bastion host, we need to use the keypair file
ssh -i <Keypair_Path> ec2-user@<Public_IP_Address>
If you want to connect to the other EC2 instances when you entering to the Bastion host you can use:
ssh -A ec2-user@<Private_IP_Address>