Setting up Terraform on Ubuntu

Setting up Terraform on Ubuntu

Sure! Here is a step-by-step guide on how to install and setup Terraform on Ubuntu:

Prerequisites

  • Ubuntu machine (local or remote)

  • sudo privileges on the machine

  • A text editor, such as Vim or nano

Installation

  1. Update package lists and install unzip if it's not already installed:

     sudo apt-get update 
     sudo apt-get install unzip
    
  2. Download the latest Terraform package for your architecture from the official website:

     wget https://releases.hashicorp.com/terraform/1.0.3/terraform_1.0.3_linux_amd64.zip
    
  3. Unzip the downloaded package:

     unzip terraform_1.0.3_linux_amd64.zip
    
  4. Move the terraform binary to the /usr/local/bin directory:

     sudo mv terraform /usr/local/bin/
    
  5. Verify the installation by running the terraform command:

     terraform version
    

    You should see the installed version of Terraform printed on the terminal.

Configuration

Once Terraform is installed, you can optionally configure some settings to improve your workflow:

  1. Set up an environment variable to store your AWS access and secret keys:

     export AWS_ACCESS_KEY_ID="your_access_key"
     export AWS_SECRET_ACCESS_KEY="your_secret_key"
    

    You can also store these keys in a file called credentials in the .aws directory located in your home directory.

  2. Set up Terraform to use a specific region:

     export AWS_DEFAULT_REGION="us-west-1"
    

Conclusion

By following these simple steps, you will have successfully installed Terraform on your Ubuntu machine and set up some basic configurations to enhance your workflow. With Terraform, you can now create, manage and automate your infrastructure resources in a scalable and efficient manner. Happy provisioning!

Did you find this article valuable?

Support Jatin Chourasia by becoming a sponsor. Any amount is appreciated!