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

  1. Download Terraform:
  2. Unzip the Package:
    • Extract the downloaded file (terraform.zip) to a folder where you want Terraform installed.
  3. 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’
    • System Properties
    • Terraform configuration
  4. Verify Installation:
    • Open Command Prompt and type terraform -v to verify installation. Terraform’s version should be displayed.

Linux

Download Terraform:

  • Open a terminal window.
  • Use wget or curl 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/
  1. Verify Installation:
    • Check the installation with terraform -v. Terraform’s version should be displayed.

macOS

  1. Download Terraform:
  2. 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:

  1. Check the installation with terraform -v

Configuration and Running Terraform

  1. 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).
    • Initialize Terraform:
      • In your project directory, run:
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.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *