Welcome! This is a simple introduction to creating cloud infrastructure with Terraform.
- 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!
- AWS Account - You need a free AWS account
- AWS CLI - Install and configure with your AWS credentials
- Terraform - Download from terraform.io
# Download or clone this project
cd terraform-tutorial# 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"# Initialize Terraform (download AWS plugin)
terraform init
# See what will be created
terraform plan
# Create everything!
terraform apply
# Type 'yes' when askedAfter terraform apply finishes, you'll see your website URL. Click it to see your application running!
Log into AWS Console and see:
- EC2 - Your web server
- DynamoDB - Your database table
- S3 - Your storage bucket
- IAM - Your security role
# Delete everything to avoid any charges
terraform destroy
# Type 'yes' when askedmain.tf- Creates your web server and storagesimple-app.tf- Creates your database and permissionsprovider.tf- Tells Terraform to use AWSvariables.tf- Settings you can changeoutputs.tf- Shows you what was createdterraform.tfvars- Your personal settings
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
- 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
Once you're comfortable with this example:
- Try changing the web page content in main.tf
- Add more resources like additional EC2 instances
- Explore other AWS services
- Learn about Terraform modules and best practices
Remember: Always run terraform destroy when you're done experimenting!
Happy Learning! 🎉