Introduction
As part of my DevOps learning journey, I recently explored Terraform, an Infrastructure as Code (IaC) tool that helps automate cloud resource provisioning. Instead of manually creating resources in AWS, Terraform allows us to define infrastructure using code.
In this blog, I’ll share how I used Terraform to create an EC2 instance, IAM user, and S3 bucket in AWS.
What is Terraform?
Terraform is an open-source Infrastructure as Code (IaC) tool developed by HashiCorp. It helps automate cloud infrastructure creation using configuration files.
With Terraform, we can:
- Automate infrastructure setup
- Manage cloud resources efficiently
- Reduce manual work
- Maintain consistent environments
Instead of creating resources manually in AWS Console, Terraform allows us to create them using code.
AWS Resources I Created
In this project, I created:
- EC2 Instance – To launch a virtual server in AWS
- IAM User – To manage permissions securely
- S3 Bucket – To store files and objects in AWS
Prerequisites
Before starting, I completed the following setup:
- AWS Account
- AWS CLI configured
- Terraform installed
- IAM permissions for resource creation
Step 1: Configure AWS Credentials
First, I configured AWS credentials using AWS CLI:
aws configure
Then I entered:
- AWS Access Key
- Secret Access Key
- Region
- Output format
This allows Terraform to communicate with AWS.
Step 2: Write Terraform Configuration
I created Terraform configuration files to define AWS resources.
The configuration included:
- Provider configuration for AWS
- EC2 instance setup
- IAM user creation
- S3 bucket configuration
Terraform uses .tf files to define infrastructure.
Step 3: Initialize Terraform
To initialize Terraform, I used:
terraform init
This command downloads required provider plugins.
Step 4: Review Infrastructure Changes
Before creating resources, I checked the execution plan:
terraform plan
This command shows what resources Terraform will create.
Step 5: Create AWS Resources
Finally, I applied the configuration:
terraform apply
After confirmation, Terraform successfully created:
✅ EC2 Instance
✅ IAM User
✅ S3 Bucket
Challenges I Faced
While working on this project, I encountered a few issues such as:
- Incorrect AMI ID
- Permission-related errors
- Terraform syntax mistakes
By checking error messages and updating configurations, I was able to resolve them.
Key Learnings
Through this project, I learned:
- Basics of Terraform
- Infrastructure as Code (IaC)
- AWS resource automation
- Terraform commands like
init,plan, andapply
Conclusion
This hands-on project helped me understand how Terraform simplifies cloud infrastructure management. Instead of manually creating AWS resources, I learned how to automate everything using code.
I’m continuing to explore more DevOps tools and cloud technologies as part of my learning journey.
Thank you for reading!




Top comments (0)