Install Terraform on Amazon Linux 2023: Step-by-Step Guide
Install Terraform on Amazon Linux 2023 using the HashiCorp repository or manual binary download. Verify installation, configure autocomplete
DevOps
Install and manage multiple Terraform versions with tfenv. Switch between versions per project, auto-detect from .terraform-version files
tfenv is a Terraform version manager — like nvm for Node.js or pyenv for Python. It lets you install multiple Terraform versions and switch between them per project. Essential when you maintain projects on different Terraform versions.
Without tfenv:
# Project A needs Terraform 1.7
# Project B needs Terraform 1.10
# You can only have one version installed
terraform version # 1.10.0 — Project A breaksWith tfenv:
cd project-a/
terraform version # 1.7.5 (auto-detected from .terraform-version)
cd project-b/
terraform version # 1.10.0 (auto-detected from .terraform-version)brew install tfenvgit clone https://github.com/tfutils/tfenv.git ~/.tfenv
# Add to PATH
echo 'export PATH="$HOME/.tfenv/bin:$PATH"' >> ~/.bashrc
source ~/.bashrctfenv --version
# tfenv 3.0.0-37-g0494129tfenv list-remote
# 1.10.0
# 1.9.8
# 1.9.7
# ...
# 1.0.0# Install specific version
tfenv install 1.10.0
# Install latest
tfenv install latest
# Install latest 1.9.x
tfenv install latest:^1.9# Set global default
tfenv use 1.10.0
# Verify
terraform version
# Terraform v1.10.0tfenv list
# 1.10.0
# 1.9.8
# * 1.7.5 (set by /home/user/project/.terraform-version)Create a .terraform-version file in your project root:
echo "1.9.8" > .terraform-versionNow terraform automatically uses that version in this directory:
cd my-project/
cat .terraform-version
# 1.9.8
terraform version
# Terraform v1.9.8
cd ../other-project/
cat .terraform-version
# 1.10.0
terraform version
# Terraform v1.10.0# In ~/.tfenv/settings or export:
export TFENV_AUTO_INSTALL=true
# Now when you cd into a project with .terraform-version,
# tfenv automatically installs that version if missingbefore_script:
- git clone https://github.com/tfutils/tfenv.git ~/.tfenv
- export PATH="$HOME/.tfenv/bin:$PATH"
- tfenv install # Reads .terraform-version
- terraform version
plan:
script:
- terraform init
- terraform plan- name: Setup tfenv
run: |
git clone https://github.com/tfutils/tfenv.git ~/.tfenv
echo "$HOME/.tfenv/bin" >> $GITHUB_PATH
- name: Install Terraform
run: tfenv install # Uses .terraform-version
- name: Plan
run: |
terraform init
terraform planFROM ubuntu:24.04
RUN apt-get update && apt-get install -y git curl unzip
RUN git clone https://github.com/tfutils/tfenv.git /root/.tfenv
ENV PATH="/root/.tfenv/bin:${PATH}"
COPY .terraform-version .
RUN tfenv install
ENTRYPOINT ["terraform"]Pin version in .terraform-version:
1.9.8Commit to Git:
git add .terraform-version
git commit -m "pin terraform version to 1.9.8"Everyone uses the same version:
git pull
tfenv install # Installs version from .terraform-version
terraform plan # Uses 1.9.8Upgrade:
echo "1.10.0" > .terraform-version
tfenv install 1.10.0
terraform init -upgrade
terraform plan # Test with new version
git add .terraform-version
git commit -m "upgrade terraform to 1.10.0"# Install and switch in one step
tfenv install 1.10.0 && tfenv use 1.10.0
# Uninstall a version
tfenv uninstall 1.7.5
# Install latest minor of a major
tfenv install latest:^1.9
# Pin latest to project
tfenv use latest
terraform version | head -1 | awk '{print $2}' | tr -d 'v' > .terraform-version| Feature | Manual Install | tfenv |
|---|---|---|
| Multiple versions | ❌ One at a time | ✅ Install many |
| Per-project version | ❌ Global only | ✅ .terraform-version |
| Team consistency | ❌ Hope everyone matches | ✅ Pinned in Git |
| Version switching | ❌ Re-download binary | ✅ tfenv use X |
| CI/CD | ❌ Hardcode in pipeline | ✅ Reads .terraform-version |
tfenv eliminates "works on my machine" version conflicts. Install it, add .terraform-version to your projects, commit to Git, and every team member automatically uses the same Terraform version. It takes 2 minutes to set up and prevents hours of debugging version-related issues.
Install Terraform on Amazon Linux 2023 using the HashiCorp repository or manual binary download. Verify installation, configure autocomplete
Install Terraform on Debian 12 Bookworm using the HashiCorp APT repository or manual binary download. Includes verification, autocomplete setup
Install AWS CLI v2 on Ubuntu 22.04 and 24.04 using the official installer, snap, or pip. Configure credentials, test with Terraform, and set up autocomplete.
Install AWS CLI v2 on Windows using winget in one command. Configure credentials, set up PowerShell autocomplete, and verify with Terraform.