Language

Setup & CLI · Lesson 6 of 30

Project Layout & Git

Source: doonops-curriculum/setup-cli--project-layout.md

Doonops lesson

Goal

Learn which file holds what — so projects do not become one giant messy file.

Simple explanation

Split recipe into small notebooks: versions, cloud login, settings (variables), main dishes (resources), results (outputs).

Technical view

Separation of concerns: versions.tf, providers.tf, variables.tf, main.tf, outputs.tf; .gitignore for state and secrets.

Think of it like

Kitchen drawers: spices (variables), appliances (providers), cooking steps (main), plated food photo (outputs).

Steps

  1. Read simple section
  2. Read analogy + diagram
  3. Copy project files
  4. Do local lab

Deep explanation

Layman words first, then technical detail — read slowly

Each file — layman meaning

  • versions.tf — minimum Terraform version (which app version)
  • providers.tf — which cloud + region (which shop you order from)
  • variables.tf — adjustable knobs (size, name, environment)
  • main.tf — actual servers, networks, databases
  • outputs.tf — print useful results after apply (IP, URL)
  • .gitignore — never upload secrets or state to GitHub
your-project/
  versions.tf
  providers.tf
  variables.tf
  main.tf
  outputs.tf
  .gitignore

Example (Doonops)

Modern HCL — names are examples, not from any third-party course

Example HCL
HCL
# .gitignore
.terraform/
*.tfstate*
*.pem
.terraform.lock.hcl

Terraform runs on your computer — copy this HCL into a folder, then follow the local lab steps below.

Check

  • Name 4 file types and purpose
  • .gitignore why needed

Project files for this lab

Full implementation folder — copy all files, then run terraform commands

Lab project files (full folder)

Copy every file below into one folder — same as a real repo module. Then run the local lab steps.

Suggested folder: Suggested path: ~/doonops-terraform/04-layout/

versions.tfSee file purpose in the code below
terraform {
  required_version = ">= 1.9.0"
}

Module check — did you get it?

2–3 quick questions before the next module

Setup — quick check

Quick check — did this module stick?

1. Why create an IAM user instead of using root?

  • Root is faster
  • Safer — limited permissions, rotatable keys
  • Terraform requires root
  • IAM is deprecated

2. Command to verify AWS CLI works locally?

  • terraform apply
  • aws sts get-caller-identity
  • git push
  • docker run