Thuta Learning
ExercisesDevOpsintermediate

Hands-On Practice Set 1

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Get comfortable with Hands-On Practice Set 1, no intimidation required
  • Be able to run terraform commands and HCL code yourself
  • Apply this concept immediately in a real project

Let's think about this for a second

This round is about putting the Basic/Intermediate concepts you've already learned into practice — telling Resource, Variable, and Output apart, finding errors in an HCL config, and writing `terraform` commands correctly are all things you'll actually do hands-on here. No single task should take more than 5 minutes.

Let's connect this to a real scenario

Task 1: Explain the difference in roles between 'Resource', 'Variable', and 'Output' in one sentence each. Task 2: Given `resource "aws_instance" "web" { instance_type = var.instance_type }`, but the `variable "instance_type"` block is never defined anywhere in the config file, predict and write down what error would occur. Task 3: Explain why the state file matters, and give an example of the risks of local state. Task 4: If `terraform plan` shows an unexpected change (drift), which two commands would you use to investigate?

Let's look at an example

text
# Task 2 - undefined variable
resource "aws_instance" "web" {
  instance_type = var.instance_type   # ERROR!
}
# No `variable "instance_type" { ... }` block exists anywhere.

Result: Terraform will error at `terraform plan` time with
something like: "Reference to undeclared input variable"

# Task 4 - investigating drift
terraform plan                        # shows what changed vs config
terraform state show <resource>       # inspect the current tracked state
You should see
You'll come away with the difference between Resource/Variable/Output, practice spotting an undefined variable error, and the commands used to investigate drift.

Try it in 5 minutes

Write your own config and deliberately introduce an undefined variable reference bug — run `terraform plan` and see for yourself what happens.

A quick word of caution

You don't need any cloud account setup for this round — it's focused purely on concepts and debugging logic.

Easy traps

  • Getting Resource/Variable/Output confused, treating them as 'all the same thing'
  • Skimming the error message in terminal output without checking which line the error is actually on

Now try it yourself

Write your own config and deliberately introduce an undefined variable reference bug — run `terraform plan` and see for yourself what happens.

You'll know it worked when: You'll come away with the difference between Resource/Variable/Output, practice spotting an undefined variable error, and the commands used to investigate drift.

Hands-On Practice Set 1 | Thuta Learning