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.
- Terraform: infrastructure as Code engine
- AWS Provider: EC2 and AMI data source
- AWS CLI: Credentials management and validation
- Configure AWS provider in fist_ec2.tf
- Run terraform init to download provider and set up the workspace.
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.
- 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.
- Edit first_ec2.tf
- Apply the terraform paln to see and whats being updated
- Tag name on my EC2 instance will be updated
- 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