OpenTofu AWS Free-Tier Lab
make validateOverview
Section titled “Overview”Student AWS free-tier IaC lab with explicit destroy and cost warnings.
What You Will Build
Section titled “What You Will Build”Architecture Diagram
Section titled “Architecture Diagram”Prerequisites
Section titled “Prerequisites”- Install or review: OpenTofu, Terraform, AWS, EC2, VPC.
- Use your own cloud account credentials and keep them out of commits.
- This project expects cloud resources, so verify budget alerts and cleanup first.
- Open the safety guide before running commands that create infrastructure.
Credentials And Cost Warning
Section titled “Credentials And Cost Warning”Cost risk is medium. Cloud target: AWS. Cloud credentials needed: Yes. Always use your own account, never commit secrets, and confirm cleanup before creating paid infrastructure.
Step-By-Step Lab
Section titled “Step-By-Step Lab”Use this flow before you run commands:
- Read the cost and credential warning above.
- Review the validation, troubleshooting, cleanup, and portfolio proof sections below.
- Follow the original project guide preserved near the bottom of this page.
- Return to the validation and cleanup checks before you capture portfolio evidence.
Validation Checks
Section titled “Validation Checks”Run the project validation command before and after meaningful changes:
make validateTroubleshooting
Section titled “Troubleshooting”- Run
make validatefirst so local tooling issues are visible early. - If a command fails, check tool versions, working directory, and required environment variables.
- For cloud failures, confirm account identity, region, quotas, and least-privilege IAM.
Cleanup
Section titled “Cleanup”Cleanup is available or expected for this lab. Use the cleanup or destroy steps in the guide below, then confirm that local clusters, containers, cloud resources, buckets, state files, and CI secrets are no longer active.
Portfolio Proof
Section titled “Portfolio Proof”- Validation command output:
make validate - Screenshot or terminal proof: Plan/apply evidence plus destroy proof
- Notes explaining what changed, what failed, and how you fixed it
- Cleanup evidence, especially for cloud or Kubernetes resources
Original Project Guide
Section titled “Original Project Guide”The original README content is preserved here for lab-specific commands and context. Headings are intentionally demoted so the page outline stays focused on the standard lab flow.
Beginner-friendly infrastructure-as-code lab that creates a tiny AWS VPC, public subnet, security group, and optional free-tier EC2 instance with OpenTofu or Terraform.
What You Learn
Section titled “What You Learn”- How OpenTofu/Terraform plans and applies infrastructure
- How providers, variables, outputs, and state work
- Why tags and destroy steps matter for cost control
- How to keep cloud labs small and reviewable
Architecture
Section titled “Architecture”flowchart TB Student["Student workstation"] --> Tofu["OpenTofu or Terraform"] Tofu --> AWS["AWS provider"] AWS --> VPC["VPC 10.52.0.0/16"] VPC --> Subnet["Public subnet"] Subnet --> SG["Security group"] SG --> EC2["Optional t3.micro nginx instance"]Cost Warning
Section titled “Cost Warning”This lab can create AWS resources. Use free-tier eligible instance types, confirm your region, restrict SSH to your own IP, and destroy everything when done.
Prerequisites
Section titled “Prerequisites”- AWS account
- AWS CLI configured
- OpenTofu, or Terraform with
TF=terraform
One-Command Local Validation
Section titled “One-Command Local Validation”make validateValidation is local: it checks formatting, initializes providers without a backend, and runs validate. It does not create AWS resources.
Review-Then-Apply Workflow
Section titled “Review-Then-Apply Workflow”cp terraform.tfvars.example terraform.tfvarsmake planmake upmake logsmake downUse Terraform instead of OpenTofu:
TF=terraform make validateTF=terraform make planTF=terraform make upTF=terraform make downmake up refuses to run until make plan has created tfplan, so students review the cloud changes first.
Troubleshooting
Section titled “Troubleshooting”tofu: command not found: install OpenTofu or prefix commands withTF=terraform.- AWS credential errors: run
aws sts get-caller-identityand confirm the expected account appears. - SSH is open to the world: set
allowed_ssh_cidrinterraform.tfvarsto your public IP with/32. - Duplicate names or stale state: run
make logsto inspect outputs, thenmake downwhen you are done.
Cleanup
Section titled “Cleanup”make downrm -f tfplanAlways confirm the destroy plan before approving it.
Student Exercises
Section titled “Student Exercises”- Add an S3 backend for remote state.
- Add a second subnet in another Availability Zone.
- Add a budget alarm.
- Convert the EC2 instance into a reusable module.
Source Files On GitHub
Section titled “Source Files On GitHub”The full learning flow stays on this page. Open GitHub only when a step asks you to inspect code, fork the lab, or download source assets.