Skip to content

it's a sample bash script for compiling the latest terraform as of now Because if you have tried to install terraform via built-in repo it was old so that's why I just try to automate that latest installation.

Notifications You must be signed in to change notification settings

yousafkhamza/Terraform_installation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 

Repository files navigation

Terraform Installation Script (Linux)

Build


Description

It's a simple bash script for terraform compilation installation. What is terraform: Terraform is an open-source infrastructure as code software tool created by HashiCorp. Users define and provide data center infrastructure using a declarative configuration language known as HashiCorp Configuration Language,


Feature

  • Terraform installation (automated with bash)
  • Compilation (installation method)

Pre-Requests

  • It's supported for Linux
-RedHat-

yum install git -y
yum install unzip -y

-Debian-

sudo apt install git -y
sudo apt install unzip -y

it depends on your operating system repository


How to Get

git clone https://github.com/yousafkhamza/Terraform_installation.git
cd Terraform_installation
chmod +x terraform.sh

If you're not intrested to clone the git repo to your machine you can run teh same via curl

curl -Ls https://raw.githubusercontent.com/yousafkhamza/Terraform_installation/main/terraform.sh | bash

Output Be Like

Newly installed server

[root@ip-172-31-43-204 ~]# /bin/bash terraform.sh
Terraform installation begins..........
Downloading Terraform From Hashicorp .............
Archive:  /tmp/terraform_1.0.6_linux_amd64.zip
  inflating: terraform
Terraform installation successful..........

The Terraform version is given below......
-----------
Terraform v1.0.6
on linux_amd64
-----------

Already installed on your server its shown to be like

[root@ip-172-31-0-141 ~]# curl -Ls https://raw.githubusercontent.com/yousafkhamza/Terraform_installation/main/terraform.sh | bash
Terrform Already Installed On The Server...........

The Terrform version is given below......
-----------
Terraform v1.0.7
on linux_amd64
-----------

Behind the Code

#!/bin/bash

# -----------------------------------------
# Terraform installation script for Linux
# -----------------------------------------

function terraform_installtion () {
    echo "Downloading Terraform From Hashicorp ............."
    wget https://releases.hashicorp.com/terraform/1.0.6/terraform_1.0.6_linux_amd64.zip -P /tmp/ >/dev/null 2>&1
    unzip /tmp/terraform_*.zip
    mv terraform /usr/bin/
    rm -f /tmp/terraform_*.zip
}

which terraform >/dev/null 2>&1
if [ $? = 0 ]; then
    echo "Terraform Already Installed On The Server..........."; echo ""
    echo "The Terraform version is given below......"
    echo "-----------"
    terraform -v
    echo "-----------"
    sleep 1
    exit 1
else
    echo "Terraform installation begins.........."
    sleep 1
    terraform_installtion
    echo "Terraform installation successful.........."; echo ""
    echo "The Terraform version is given below......"
    echo "-----------"
    terraform -v
    echo "-----------"
    sleep 1
    exit 1
fi

Conclusion

it's a sample bash script for compiling the latest terraform as of now Because if you have tried to install terraform via built-in repo it was old so that's why I just try to automate that latest installation.

⚙️ Connect with Me


About

it's a sample bash script for compiling the latest terraform as of now Because if you have tried to install terraform via built-in repo it was old so that's why I just try to automate that latest installation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages