Terraform is one of the best infrastructure as code tools on the market. It allows you to create, change and enhance structure securely on the most popular service providers.
You can use it to manage Cloud Compute, Networking, Load Balancers and DNS efficiently using simple Declarative Programming Language. It is available on Github. In this article, you will find step by step guide for installing Terraform on Ubuntu 18.04 and CentOS 7.
Installing Terraform on Ubuntu 18.04 / CentOS 7
- First, ensure that wget is installed on your PC by using the following command in the Terminal:
$ sudo apt-get install wget # Ubuntu $ sudo yum install wget # CentOS
- Now, get Terraform archive.
export VER="0.11.8" wget https://releases.hashicorp.com/terraform/${VER}/terraform_${VER}_linux_amd64.zip
- After downloading, extract the archive by typing the following command:
$ sudo apt-get install unzip # Ubuntu $ sudo yum install unzip # CentOS 7 $ unzip terraform_${VER}_linux_amd64.zip Archive: terraform_0.11.8_linux_amd64.zip inflating: terraform
- A terraform binary file has been created in the working directory. Now, you have to move the file to the directory /usr/local/bin. Type the following line:
sudo mv terraform /usr/local/bin/
- Now, all the users in your PC can get access to Terraform. Type these lines to verify the accessibility:
$which terraform /usr/local/bin/terraform
- Check the version number of Terraform.
$ terraform -v Terraform v0.11.8
- Now, verify the functionality of Terraform.
# terraform Usage: terraform [-version] [-help] <command> [args] The available commands for execution are listed below. The most common, useful commands are shown first, followed by less common or more advanced commands. If you're just getting started with Terraform, stick with the common commands. For the other commands, please read the help and docs before usage. Common commands: apply Builds or changes infrastructure console Interactive console for Terraform interpolations destroy Destroy Terraform-managed infrastructure env Workspace management fmt Rewrites config files to canonical format get Download and install modules for the configuration graph Create a visual graph of Terraform resources import Import existing infrastructure into Terraform init Initialize a Terraform working directory output Readan output from a state file plan Generate and show an execution plan providers Prints a tree of the providers used in the configuration push Upload this Terraform module to Atlas to run refresh Updatelocal state file against real resources show Inspect Terraform state or plan taint Manually mark a resource for recreation untaint Manually unmark a resource as tainted validate Validates the Terraform files version Prints the Terraform version workspace Workspace management All other commands: debug Debug output management (experimental) force-unlock Manually unlock the terraform state state Advanced state management
Conclusion
If everything works correctly, Terraform has been successfully installed in your PC. Now, you have the power to build, change and combine infrastructure efficiently and safely.
Check out these top 3 Linux hosting services
HostArmada
Hostinger
FastComet
- Looking for Top web hosting? Clicking on this link can be the solution.