Skip to main content
Welcome to this lesson on preparing your local machine to run Terraform. This guide walks you through the minimal, practical steps required to get a working Terraform environment for exercises and labs, with verification commands so you can confirm each step completed successfully. What you’ll get from this lesson
  • Clear installation options for Terraform across macOS, Linux, and Windows
  • Recommended code editor setup (Visual Studio Code) and useful extensions
  • How to configure cloud provider credentials (AWS, Azure, GitHub) so Terraform can authenticate securely
  • A short checklist of basic Terraform workflow commands to validate your environment

Installing Terraform

You can install Terraform either via your platform’s package manager or by downloading the official binary from HashiCorp: https://developer.hashicorp.com/terraform/downloads. Use the method that suits your environment (package managers keep Terraform up to date; manual downloads give you more control). Package-manager examples After installation, verify Terraform is available:
You should see Terraform’s version and the installed provider plugin versions. If you see “command not found”, confirm the binary is on your PATH. I recommend Visual Studio Code as a lightweight, extensible editor for Terraform HCL files. Suggested extensions and formatting

Setting up cloud provider credentials

Terraform uses provider plugins to interact with cloud APIs. Before executing Terraform code that targets a cloud provider, configure credentials on the machine where you run Terraform. Credential patterns and examples Examples and notes
  • AWS: Run aws configure to create ~/.aws/credentials. The Terraform AWS provider reads the default profile automatically; you can also specify a profile in the provider block.
  • Azure: Run az login for interactive work. For CI/CD, create a service principal and export ARM_CLIENT_ID, ARM_CLIENT_SECRET, ARM_SUBSCRIPTION_ID, and ARM_TENANT_ID.
  • GitHub: Create a PAT with the minimum scopes required (for example, repo and workflow) and export it as GITHUB_TOKEN for use by the GitHub Terraform provider.
When possible, prefer using CLI tools (for example aws, az) to authenticate locally and use environment variables or credential files for automation. This avoids hard-coding secrets in your Terraform configuration.

Basic Terraform workflow checks

Once Terraform is installed and credentials are configured, validate your environment by running these commands inside an empty working directory (or a directory with your Terraform configurations).
  1. Initialize the working directory (downloads providers and configures the backend):
  1. Format and validate your configuration files:
  1. Preview changes:
  1. Apply changes (prompts for confirmation by default):
Quick verification checklist
Never commit provider credentials, personal access tokens, or other secrets to version control. Use environment variables, CLI-authenticated sessions, or a secrets manager for automation.

Wrapping up

This lesson covered the essentials to prepare your machine for Terraform exercises:
  1. Install Terraform (package manager or HashiCorp binary)
  2. Configure a code editor (Visual Studio Code + extensions)
  3. Set up cloud provider credentials (AWS, Azure, GitHub)
  4. Verify the basic Terraform workflow (init, fmt, validate, plan, apply)
You’re now ready to start the lab exercises. Begin by installing Terraform on your platform, then configure your editor and authenticate to your target cloud provider.

Watch Video