Search for a command to run...
A comprehensive guide for installing and configuring HashiCorp Terraform, an Infrastructure as Code (IaC) tool for building, changing, and versioning infrastructure safely and efficiently.
Terraform is HashiCorp's Infrastructure as Code (IaC) tool that lets you define both cloud and on-prem resources in human-readable configuration files that you can version, reuse, and share.
# Add HashiCorp GPG key
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
# Add HashiCorp repository
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
# Update and install Terraform
sudo apt update
sudo apt install terraform
# Check Terraform version
terraform version
# Initialize Terraform in a directory
terraform init
# Add to ~/.bashrc
terraform -install-autocomplete
Common environment variables to consider:
# Provider-specific auth (example for AWS)
export AWS_ACCESS_KEY_ID="your_access_key"
export AWS_SECRET_ACCESS_KEY="your_secret_key"
export AWS_DEFAULT_REGION="your_region"
# Terraform specific
export TF_LOG=DEBUG # For debugging
export TF_VAR_name="value" # For variables
State Management
Security
Code Organization
Provider Plugin Issues
# Clear plugin cache
rm -rf ~/.terraform.d/plugins
terraform init -upgrade
State Lock Issues
# Force unlock (use with caution)
terraform force-unlock LOCK_ID
Version Conflicts
# Use specific version
terraform init -upgrade
terraform providers
Authentication Errors
Network Issues
Complete guide for installing and configuring Azure Command Line Interface (CLI) across different operating systems.
Complete guide for installing and setting up Ansible, an agentless automation tool that enables infrastructure as code, configuration management, and application deployment using simple YAML syntax.