Guide to install and verify Terraform, configure VS Code, set cloud provider credentials for AWS Azure GitHub, and run basic Terraform workflow commands
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
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
Platform
Recommended approach
Example command / notes
macOS
Homebrew
brew install terraform
Ubuntu / Debian
HashiCorp apt repository or manual binary
Follow HashiCorp’s repo instructions to enable apt updates
RHEL / CentOS / Fedora
HashiCorp yum/dnf repository or manual binary
Configure HashiCorp yum/dnf repo for updates
Windows
Chocolatey or official MSI/zip
choco install terraform or download MSI from HashiCorp
After installation, verify Terraform is available:
# Verify Terraform installationterraform -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.
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
Provider
Typical local auth method
Environment variables / files
AWS
Configure AWS CLI or set env vars
~/.aws/credentials via aws configure, or AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN
Azure
Use az login for interactive sessions; service principal for automation
Service principal vars: ARM_CLIENT_ID, ARM_CLIENT_SECRET, ARM_SUBSCRIPTION_ID, ARM_TENANT_ID
GitHub
Create 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.
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).
Initialize the working directory (downloads providers and configures the backend):
terraform init
Format and validate your configuration files:
terraform fmtterraform validate
Preview changes:
terraform plan
Apply changes (prompts for confirmation by default):
terraform apply
Quick verification checklist
Command
Purpose
Expected result
terraform -version
Confirms Terraform binary is installed
Displays Terraform and provider plugin versions
terraform init
Fetches providers and initializes backend
Completed initialization without errors
terraform fmt
Formats HCL files
Files are formatted (or no changes)
terraform validate
Static validation of configs
No errors reported
terraform plan
Shows proposed changes
Plan 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.
This lesson covered the essentials to prepare your machine for Terraform exercises:
Install Terraform (package manager or HashiCorp binary)
Configure a code editor (Visual Studio Code + extensions)
Set up cloud provider credentials (AWS, Azure, GitHub)
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.