Skip to content

Alii2121/IaC-Terraform-AWS-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IaC-Terraform-AWS-Project

Creating the following infrastructure using Terraform

photo1674223144


To Deploy this infrastructure on your account

1- clone this repo

git clone https://github.com/Alii2121/IaC-Terraform-AWS-Project.git

2- Create your own key-pair and use in EC2/main.tf

3- Make sure to pass your credentials correctly in main.tf file provider block

4- Comment the backend in RemoteStateFile.tf and change S3 name to a unique one

5- Make sure you Have installed latest version of Terraform and run the following commands inside the project directory

terraform init 
terraform apply

6- uncomment the backend and apply step 5 again


Bonus

  • Added Ansible files to configure EC2 machines using configuration management tool tou use it instead of provisioner in Terraform
  • Ansible uses 1 of the EC2 public machines as a bastion host to connect to the private ones
  • Installs Nginx on all machines then copy a script and run it on the machines
  • Pass any script to the ansible files to cinfigure the machines as you like
  • The provided IPS are dynamic not static so make sure to clear the all-ips file and use the IPS generated on applying terraform

Screenshots of output

Enviroment

Screenshot from 2023-01-30 14-39-47


2 Public EC2s 2 Private EC2s

Screenshot from 2023-01-31 17-46-10


Security Groups

Screenshot from 2023-01-31 17-46-30 Screenshot from 2023-01-31 17-57-20


Elastic IP

Screenshot from 2023-01-31 17-46-37


Load Balancers (External and Internal facing)

Screenshot from 2023-01-31 17-46-47

Screenshot from 2023-01-31 17-47-00

Screenshot from 2023-01-31 17-47-10


Target Groups

Screenshot from 2023-01-31 17-55-07

Screenshot from 2023-01-31 17-55-17

Screenshot from 2023-01-31 17-55-25


VPC and Subnets

Screenshot from 2023-01-31 17-55-54

Screenshot from 2023-01-31 17-56-07


Route Tables

Screenshot from 2023-01-31 17-56-21

Screenshot from 2023-01-31 17-56-28


Internet gateway & NAT gateway

Screenshot from 2023-01-31 17-56-42

Screenshot from 2023-01-31 17-57-06


S3 Bucket and DynamoDB used for statelock of terrafrom.tfstate file

Screenshot from 2023-01-31 17-57-55

Screenshot from 2023-01-31 17-58-03

Screenshot from 2023-01-31 17-58-10

Screenshot from 2023-01-31 17-58-30


ALB-DNS Output

Screenshot from 2023-01-31 18-21-33

Screenshot from 2023-01-31 18-21-42


Proxy Configuration

            sudo apt update -y
            sudo apt install nginx -y 
            echo 'server { \n listen 80 default_server; \n  listen [::]:80 default_server; \n  server_name _; \n  location / { \n  proxy_pass http://${var.internal-LB-DNS}; \n  } \n}' > default
            sudo mv default /etc/nginx/sites-enabled/default
            sudo systemctl restart nginx
            sudo apt install curl -y

Thank You !

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published