Terraform with AWS

Terraform Project

Project Overview:

Demonstrate end to end infrastructure as code (IaC) skills by provisioning, updating and destroying an Amazon EC2 instance using Terraform. This project showcases automation, scalability and disciplined resource management critical skills for cloud engineering and DevOps roles.

Architecture Overview

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

Steps taken to complets this project :

1. Initialize Project

Terraform
Terraform
Terraform

- Configure AWS provider in fist_ec2.tf
- Run terraform init to download provider and set up the workspace.


2. Terraform plan

Terraform

Generate detailed plan of actions:
- Resources to create
- Resources to upadte
- Resources to destroy

Safe checks: You can review the plan before applying it, which prevents accidental deletions or costly mistakes. This is why Terraform is considered safe and predictable.


3. Terraform apply

Terraform
Terraform
Terraform
Terraform

- Reads configuration: Terraform loads your .tf files and variables.
- Compares state: It checks the current state of your infrastructure (from the terraform.tfstate file and the cloud provider).
- Generates a plan: If you haven’t provided a saved plan file, Terraform automatically runs a plan internally.
- Prompts for approval: By default, it shows you the plan and asks for confirmation before making changes.
- Executes changes: Once approved, Terraform communicates with the provider (AWS, Azure, GCP, etc.) to create, update, or destroy resources.
- Updates state file: After applying, Terraform records the new state in terraform.tfstate so it knows what exists for future runs.


4. Updating the EC2 instance

Terraform
Terraform

- Edit first_ec2.tf
- Apply the terraform paln to see and whats being updated

5.Terraform apply

Terraform
Terraform
APIGateway

- Tag name on my EC2 instance will be updated

6. Delete the resources

frontend
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