How to install the terraform for window , linux and mac os with step by step instructions
Installing Terraform and running it on your local machine involves a few steps. Below are step-by-step instructions for Windows, Linux, and macOS:
Windows
- Download Terraform:
- Go to Terraform Downloads and download the appropriate package for Windows.
- Unzip the Package:
- Extract the downloaded file (
terraform.zip
) to a folder where you want Terraform installed.
- Extract the downloaded file (
- Add Terraform to the System Path:
- Search for ‘Edit the system environment variables’ in the start menu and open it.
- Click on ‘Environment Variables’ in the System Properties window.
- Under ‘System Variables’, find and select the ‘Path’ variable and click ‘Edit’.
- Click ‘New’ and add the path to the folder where you extracted Terraform.
- Click ‘OK’
- Verify Installation:
- Open Command Prompt and type
terraform -v
to verify installation. Terraform’s version should be displayed.
- Open Command Prompt and type
Linux
Download Terraform:
- Open a terminal window.
- Use
wget
orcurl
to download Terraform. Replace[VERSION]
with the desired version:
wget https://releases.hashicorp.com/terraform/[VERSION]/terraform_[VERSION]_linux_amd64.zip
Unzip the Package:
- Unzip the downloaded file:
unzip terraform_[VERSION]_linux_amd64.zip
Move the Terraform Binary to a System Path:
- Move the Terraform binary to a directory in your system’s PATH, like
/usr/local/bin
:
sudo mv terraform /usr/local/bin/
- Verify Installation:
- Check the installation with
terraform -v
. Terraform’s version should be displayed.
- Check the installation with
macOS
- Download Terraform:
- Go to Terraform Downloads and download the appropriate package for macOS.
- Unzip the Package:
- Open a terminal window.
- Use
unzip
to extract the downloaded file:
unzip ~/Downloads/terraform_[VERSION]_darwin_amd64.zip
3.Move the Terraform Binary to a System Path:
- Move the Terraform binary to a directory in your system’s PATH, like
/usr/local/bin
:
sudo mv terraform /usr/local/bin/
4.Verify Installation:
- Check the installation with
terraform -v
Configuration and Running Terraform
- Initialize a New Terraform Project:
- Create a new directory for your Terraform project:
mkdir my-terraform-project
cd my-terraform-project
- Create a
.tf
file, for example,main.tf
.- Write Your Configuration:
- Open
main.tf
with a text editor. - Add Terraform configuration code. For example, you could write a configuration to provision an AWS EC2 instance (note: you need to have AWS credentials configured for this).
- Open
- Initialize Terraform:
- In your project directory, run:
- Write Your Configuration:
terraform init
- his command initializes the Terraform configuration, downloading any necessary plugins and setting up the workspace.
Remember to check Terraform documentation or specific cloud provider documentation for detailed configurations tailored to your project needs.