Skip to content

// A beginner-friendly guide to setting up AWS infrastructure using Terraform! Learn how to automate and manage cloud resources with ease. //

License

Notifications You must be signed in to change notification settings

NotHarshhaa/AWS-Terraform-Workshop

Repository files navigation

🌍 AWS Terraform Workshop for BeginnersπŸš€

A beginner-friendly guide to setting up AWS infrastructure using Terraform! Learn how to automate and manage cloud resources with ease.


πŸ“Œ What You'll Learn

βœ… Deploy AWS Resources using Terraform
βœ… Manage Infrastructure as Code (IaC)
βœ… Use Remote State Storage with S3 + DynamoDB
βœ… Create VPC, Subnets, and EC2 Instances βœ… Configure Security Groups and Networking βœ… Apply Best Practices for Terraform Code Structure


πŸ—οΈ Project Structure (What's Inside?)

AWS-Terraform-Workshop/
│── scripts/          # Shell scripts for user data and setup
β”‚   └── user_data.sh  # Bootstrap script for EC2 instances
│── main.tf           # Main Terraform configuration (VPC, EC2, networking)
│── variables.tf      # Input values for easy customization
│── outputs.tf        # Output values of deployed resources
│── backend.tf        # Remote state setup (S3 + DynamoDB)
│── backend-variables.tf # Variables for backend configuration
│── provider.tf       # AWS provider configuration
│── terraform.tfvars.example # Example variable values
│── README.md         # This guide! πŸ“–

πŸš€ Getting Started (Step-by-Step)

1️⃣ Install Required Tools

πŸ”Ή Download Terraform (v1.0.0 or newer) πŸ”Ή Install AWS CLI and set up credentials using:

aws configure

πŸ”Ή Create an S3 bucket & DynamoDB table for storing Terraform state:

# Create S3 bucket
aws s3 mb s3://your-terraform-state-bucket --region us-east-1

# Create DynamoDB table (with 'LockID' as partition key)
aws dynamodb create-table \
    --table-name your-terraform-lock-table \
    --attribute-definitions AttributeName=LockID,AttributeType=S \
    --key-schema AttributeName=LockID,KeyType=HASH \
    --billing-mode PAY_PER_REQUEST \
    --region us-east-1

2️⃣ Clone the Project & Configure Variables

git clone https://github.com/NotHarshhaa/AWS-Terraform-Workshop.git
cd AWS-Terraform-Workshop

# Create a tfvars file with your specific values
cp terraform.tfvars.example terraform.tfvars
# Edit the terraform.tfvars file with your preferred editor

3️⃣ Initialize Terraform with Backend Configuration

# Basic initialization
terraform init

# Or with custom backend configuration
terraform init \
  -backend-config="bucket=your-terraform-state-bucket" \
  -backend-config="dynamodb_table=your-terraform-lock-table" \
  -backend-config="region=us-east-1"

πŸ‘‰ This sets up Terraform by downloading necessary plugins and configuring remote state.


4️⃣ Plan & Apply Changes

# Preview changes
terraform plan -out=tfplan

# Apply the saved plan
terraform apply tfplan

# Or directly apply (will prompt for confirmation)
terraform apply

⚑ This will create a complete infrastructure including:

  • VPC with proper CIDR blocks
  • Public subnet with internet connectivity
  • Security groups with configurable ports
  • EC2 instance with Apache web server

5️⃣ Test the Deployment & View Outputs

# View all the output values
terraform output

# Get a specific output value (e.g., web server URL)
terraform output web_url

# SSH to your instance
terraform output ssh_connection_string
# Then modify the command with the actual path to your key file

6️⃣ Destroy Infrastructure (When Finished)

# Preview what will be destroyed
terraform plan -destroy

# Destroy all resources
terraform destroy

β›” This will delete all deployed AWS resources.


πŸ“ Best Practices for Beginners

πŸ”Ή Always use Remote State – Store Terraform state in S3 to prevent conflicts.
πŸ”Ή Use Variables and Outputs – Parameterize your code for flexibility. πŸ”Ή Separate User Data Scripts – Keep bootstrap scripts in separate files. πŸ”Ή Apply Proper Tagging – Tag resources consistently for better management. πŸ”Ή Use Dynamic Blocks – For repeatable resource configurations. πŸ”Ή Check Plan Before Applying – Always run terraform plan first!
πŸ”Ή Security First – Restrict security group rules to minimum required access.


🀝 Contributing

πŸ”Ή Found something to improve? Open a pull request!
πŸ”Ή Have questions? Feel free to open an issue!
πŸ”Ή Want to extend? Add more resources like RDS, S3, or Lambda!


πŸ“œ License

πŸ“ This project is licensed under MIT License – Free to use and modify!

πŸ“š Additional Resources

πŸ”Ή Terraform Documentation πŸ”Ή AWS Provider Documentation πŸ”Ή Terraform Best Practices

πŸš€ Happy Terraforming! 🌍


⭐ Hit the Star!

If you find this repository helpful and plan to use it for learning, please consider giving it a star ⭐. Your support motivates me to keep improving and adding more valuable content! πŸš€


πŸ› οΈ Author & Community

This project is crafted with passion by Harshhaa πŸ’‘.

I’d love to hear your feedback! Feel free to open an issue, suggest improvements, or just drop by for a discussion. Let’s build a strong DevOps community together!


πŸ“§ Let's Connect!

Stay connected and explore more DevOps content with me:

LinkedIn GitHub Telegram Dev.to Hashnode


πŸ“’ Stay Updated!

Want to stay up to date with the latest DevOps trends, best practices, and project updates? Follow me on my blogs and social channels!

Follow Me

About

// A beginner-friendly guide to setting up AWS infrastructure using Terraform! Learn how to automate and manage cloud resources with ease. //

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published