How to Install & Configure Terraform on Ubuntu

Terraform is an infrastructure as a code platform(IaaC) developed by HashiCorp. We can simply write code in the human-readable format following HashiCorp Configuration Language (HCL) and deploy it to get the infrastructure in the cloud. Terraform is supported in many cloud providers like Google, Amazon, Alibaba, etc.



  • Download the latest version of Terrafrom.




  • Unzip the download file.


sudo apt install zip -y

                sudo unzip


  • move terraform to /usr/local/bin/ to execute the command.


sudo mv terraform /usr/local/bin/


  • Check the version.


terraform version


  • Once Terraform is installed,then create a folder.


mkdir project


  •    Go to project directory and create files:-

vim    (creates all the resources)

vim  ( define the variables type and optionally set a default value)

vim (store the results of a module operation)


  • Initializing terraform will make the necessary configuration. So, execute the following command.


terraform init


  •  Deploy the code.


terraform apply 


  • Destroy the above infrastructure.


terraform destroy


Leave a Reply