Terraform with AWS

Project Overview:

This project demonstrates how to fully automate the deployment of a web server on AWS using Terraform. The goal was to provision a secure EC2 instance, enable SSH access, and automatically deploy a simple HTML website using cloud-init. This showcases my ability to use Infrastructure as Code (IaC), manage AWS resources programmatically, and build repeatable, production-ready infrastructure.

Using Terraform, I created an SSH key pair, security groups, and an Ubuntu EC2 instance. Cloud-init was used to install Nginx and serve a custom HTML page immediately after the instance launched. The project highlights skills in AWS, Terraform, Linux server management, SSH, and automated web deployment.

Architecture Overview

- Terraform: infrastructure as Code engine
- AWS Provider: EC2 and AMI data source
- AWS CLI: Credentials management and validation
- Security Group

Steps taken to complets this project :

1. Initialize Project

Terraform
Terraform
Terraform

Defined the requirements:
- One EC2 instance
- SSH access for administration
- Http on port 80 for web-server
- One Elastic IP


2. Terraform plan

Terraform
Terraform

- Previews changes before they are applied to AWS.
- Compares your Terraform configuration with the existing cloud infrastructure.
- Identifies resources that will be created, updated, or deleted.
- Ensures accuracy and prevents mistakes before deployment.
- Provides a safe “dry run” so you can review infrastructure changes with confidence.


3. Terraform apply

Terraform
Terraform

- Executes the changes defined in your Terraform configuration.
- Creates, updates, or deletes cloud resources exactly as shown in the plan.
- Builds real infrastructure on AWS based on your code.
- Prompts for confirmation before making any changes.
- Ensures consistent, automated deployment of cloud environments.


4. SSH into My EC2 Instance

Terraform

- Securely connects to the EC2 server using an encrypted SSH connection.
- Provides terminal access to manage and configure the Linux instance directly.
- Allows installation of software, updates, and services on the server.
- Enables file management such as creating folders, editing files, and monitoring logs.
- Gives full administrative control to run commands and maintain the server environment.

5.Creating a EC2 web server using terraform

Terraform
Terraform
APIGateway
APIGateway

- Automates deployment of a fully configured web server on AWS.
- Provision EC2 instance with the required AMI and instance type.
- Installs and starts a web server (e.g., Apache or Nginx) using user data scripts.
- Creates security groups to allow HTTP and SSH access.
- Ensures repeatable infrastructure, allowing the web server to be rebuilt consistently anytime.

6. Terraform Destroy

frontend
frontend

- To delete the EC2 instance runninng on AWS run the "terraform destroy" in the command Prompt
- after the prompt has done runing you will be alerted on the command prompt
- Go to AWS console and verify that your EC2 instance has been Terminated