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
PlatformRecommended approachExample command / notes
macOSHomebrewbrew install terraform
Ubuntu / DebianHashiCorp apt repository or manual binaryFollow HashiCorp’s repo instructions to enable apt updates
RHEL / CentOS / FedoraHashiCorp yum/dnf repository or manual binaryConfigure HashiCorp yum/dnf repo for updates
WindowsChocolatey or official MSI/zipchoco install terraform or download MSI from HashiCorp
After installation, verify Terraform is available:
# Verify Terraform installation
terraform -version
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
terraform fmt

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
ProviderTypical local auth methodEnvironment variables / files
AWSConfigure AWS CLI or set env vars~/.aws/credentials via aws configure, or AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN
AzureUse az login for interactive sessions; service principal for automationService principal vars: ARM_CLIENT_ID, ARM_CLIENT_SECRET, ARM_SUBSCRIPTION_ID, ARM_TENANT_ID
GitHubCreate a Personal Access Token (PAT)Set GITHUB_TOKEN or GH_TOKEN in the environment, or use provider block config
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):
terraform init
  1. Format and validate your configuration files:
terraform fmt
terraform validate
  1. Preview changes:
terraform plan
  1. Apply changes (prompts for confirmation by default):
terraform apply
Quick verification checklist
CommandPurposeExpected result
terraform -versionConfirms Terraform binary is installedDisplays Terraform and provider plugin versions
terraform initFetches providers and initializes backendCompleted initialization without errors
terraform fmtFormats HCL filesFiles are formatted (or no changes)
terraform validateStatic validation of configsNo errors reported
terraform planShows proposed changesPlan output lists resources to create/update/destroy
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