Skip to content

devopseduhubspot/terraform-tutorial

Repository files navigation

🚀 My First Terraform Application

Welcome! This is a simple introduction to creating cloud infrastructure with Terraform.

What You'll Create

  • Web Server - A simple website running on Amazon EC2
  • Database - A DynamoDB table to store data
  • Storage - An S3 bucket for files
  • Security - Firewall rules to protect your server
  • Permissions - IAM role so your server can access the database

💰 Cost: Everything uses AWS Free Tier - no charges for learning!

📋 Before You Start

  1. AWS Account - You need a free AWS account
  2. AWS CLI - Install and configure with your AWS credentials
  3. Terraform - Download from terraform.io

🚀 Let's Get Started!

Step 1: Get the Code

# Download or clone this project
cd terraform-tutorial

Step 2: Configure Your Settings

# Copy the example settings
cp terraform.tfvars.example terraform.tfvars

# Edit terraform.tfvars with your information
# Change project_name to something unique like "your-name-first-app"

Step 3: Create Your Infrastructure

# Initialize Terraform (download AWS plugin)
terraform init

# See what will be created
terraform plan

# Create everything!
terraform apply
# Type 'yes' when asked

Step 4: See Your Application!

After terraform apply finishes, you'll see your website URL. Click it to see your application running!

Step 5: Explore AWS Console

Log into AWS Console and see:

  • EC2 - Your web server
  • DynamoDB - Your database table
  • S3 - Your storage bucket
  • IAM - Your security role

Step 6: Clean Up (Important!)

# Delete everything to avoid any charges
terraform destroy
# Type 'yes' when asked

📁 Files Explanation

  • main.tf - Creates your web server and storage
  • simple-app.tf - Creates your database and permissions
  • provider.tf - Tells Terraform to use AWS
  • variables.tf - Settings you can change
  • outputs.tf - Shows you what was created
  • terraform.tfvars - Your personal settings

🆘 Need Help?

Common Issues:

  • Access Denied: Make sure AWS CLI is configured with your credentials
  • Bucket name exists: Change your project_name in terraform.tfvars
  • Region not supported: Try "us-east-1" or "us-west-2"

Getting Help:

  • Check the AWS Free Tier limits
  • Make sure you have permissions to create EC2, S3, DynamoDB, and IAM resources
  • Ask your instructor if you're in a training session

🎓 What You Learned

  • How to write Terraform configuration files
  • How to create cloud infrastructure automatically
  • How different AWS services work together
  • How to manage infrastructure as code
  • How to clean up resources to avoid charges

🎯 Next Steps

Once you're comfortable with this example:

  1. Try changing the web page content in main.tf
  2. Add more resources like additional EC2 instances
  3. Explore other AWS services
  4. Learn about Terraform modules and best practices

Remember: Always run terraform destroy when you're done experimenting!


Happy Learning! 🎉

About

terraform tutorial

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages