Configuration
You declare the result: a resource, inputs, and outputs. The configuration is reviewable and can be rerun.
Chapter 1 of 24
Write a tiny declaration, ask the CLI to explain the change, and stop before anything reaches AWS.
You declare the result: a resource, inputs, and outputs. The configuration is reviewable and can be rerun.
The CLI compares the declaration with its state and shows the actions it would take. A plan is the decision point.
Only an explicit apply changes infrastructure. This chapter never reaches that step.
State maps configuration addresses to real objects. Later chapters cover locking, storage, and recovery.
Both use HCL and support this course's shared configuration. Install Terraform from the official Terraform installation guide or OpenTofu from the official OpenTofu installation guide. Keep a workspace's state with the one CLI you choose.
terraform version
tofu version
Compare the installed versions with the compatibility contract before starting a lab. The contract, not copied snippets, records the course pins and supported ranges.
This first lab has no provider and needs no AWS login. Future AWS labs do. Prefer SSO or IAM Identity Center over long-lived access keys.
aws sso login --profile learning
aws sts get-caller-identity --profile learning
aws configure get region --profile learning
| Check | Why it matters |
|---|---|
| Account ID and ARN | Confirms the identity and account that a provider will use. |
| Profile name | Keeps an intentional learning profile separate from personal or production work. |
| Region | Resources and prices vary by region. Make it explicit before apply. |
Open the lab README. Its terraform_data resource is built in, so it declares no AWS resource and downloads no third-party provider.
cd learn-terraform/labs/01-first-plan
terraform init
terraform plan
cd learn-terraform/labs/01-first-plan
tofu init
tofu plan
Use one command pair, not both in the same working directory. The configuration has the shared language constraint from the course design and is exercised with the current CLI ranges in COMPATIBILITY.md.
Expect one resource to add and one output. A value computed by a new resource is unknown until an apply, so the plan shows the input now and the output as pending.
+ input = "hello, builder"
+ output = (known after apply)
Plan: 1 to add, 0 to change, 0 to destroy.
Changes to Outputs:
+ message = (known after apply)
terraform_data.welcome.hello, builder; the output is known only after apply.provider "aws" block and no cloud resource.If init reports that the CLI version is unsupported, inspect terraform version or tofu version, then compare it with the compatibility contract. Do not loosen the version rule to make an old installation pass.
If the plan is empty or shows unexpected resources, stop and confirm that you are in labs/01-first-plan and that only the lab's main.tf is present.
terraform plan or tofu plan.1 to add, 0 to change, 0 to destroy.hello, builder and the output is known after apply.No cleanup is required because this lab intentionally ends at plan. If you later run apply while experimenting, use terraform destroy or tofu destroy with the same CLI before moving on.
plan create infrastructure?No. It calculates and presents proposed actions. apply performs them.
The same configuration can target a different account or region through credentials and provider settings. That is a meaningful change in blast radius.
It uses the built-in terraform_data resource and contains no AWS provider or AWS resource.
IaC makes desired state reviewable, but safety comes from reading plans and keeping identity context explicit. You now have a zero-cost workspace that demonstrates the configuration, init, plan, and output loop.
Next: Chapter 2, HCL as a Language, is planned. Return to the course index for the roadmap.