Terraform

 ///////////////////////

https://linuxdady.com/how-to-install-terraform/

////////////////////////

How to install terraform | terraform installation in Linux

In our previous tutorial we have discussed about introduction of terraform. Today in this tutorial we will explain how to install terraform in Linux. Remember one thing HashiCorp distributes Terraform as a binary package.To install Terraform, find the appropriate package for your system and download it as a zip archive.

Download terraform binary package

We are going to download latest version of terraform, if anyone need lower version visit to terraform official website. There are all version available and download your required version accordingly. We can use wget or curl command to download the package from terraform official website. 

How to install terraform 

Now let’s unpack the terraform binary from the zip file, If zip package is not installed then run below command first then unzip.

Unzip the terraform download package and run the below command.

move the binary of terraform form /tmp directory to /usr/local/bin directory where our all binary file we have, and after that change its ownership to the root user.

Verify terraform version

Our terraform package has been installed now check terraform version at our machine by running below command. 

if anyone are getting error “bash: terraform: command not found” it means our path variable is not set properly. We have to set this manually. Let do it.

Now we need to make path permanent so open the below path and make entry as given below on the top of file and the save it. 

[Click & Read:–  What is terraform in details ]

[Click & Read:–  Ansible ad hoc method in simple way for beginners]

if you want to make it globally then open ~/.profile file and make the entry accordingly. After setting the path variable it will show the terraform version properly.

Start with terraform and run some basic command

Up to here we have completed how to install terraform. Now let see some basic command. we will discuss latter commands in details now we are running all commands for testing purpose. 

We can see the list of commands available to us. In this chapter we’re going to focus on three of main commands:

  • plan: This command will tell what changes we are going to make means in dry mode it will run our changes in our infrastructure.
  • apply: When we are sure and want to apply our changes into our infrastructure.
  • destroy: Suppose we want to destroy infrastructure.

Conclusion :- How to install terraform

In this tutorials we have learnt how to install terraform in Linux and explained how to export terraform path variable. If anyone still have any query or suggestion please write me in comment box. I will try my best to resolve them query.

Interview question

  1. Which is the latest version of terraform on which you have worked?
  2. What are the differences between Terraform V-11 and Terraform V-12?
  3. Why use to terraform we have many other tools like Cloud formation etc.

////////////////////////

What is terraform and its use case for beginners?

Terraform demand is increasing day by day in IT industry. So before moving next, we should know what is terraform and it’s use cases. Terraform is an “Infrastructure as Code” tool for building and managing infrastructure efficiently. Infrastructure as code means we can write code for our hardware infrastructure. Then we can deploy it without manually intervention. 

Is terraform licensed or open source?

This is written by the team at HashiCorp. It is open source and licensed under the Mozilla Public License, version 2.0. HashiCorp also sells an enterprise version of it.

How terraform works?

We define the list of resources and configuration required for our infrastructure in templates. Terraform examines each resource and uses a graph-based approach to model and apply the desired state. Each resource is placed inside the graph, its relationships with other resources are calculated, and each resource is automatically built in the correct order to produce our infrastructure. This means we never have to think about modeling these complex relationships. Terraform does it for us.

what is terraform and its use cases

Where terraform is more preferable?

This is primarily used to manage Cloud-based and Software-as-a-Service (SaaS) infrastructure. But also supports various on-premise resources such as Docker and VMWare vSphere. Terraform can manage hosts, compute resources, data and storage, networking, as well as SaaS services like CDNs, monitoring tools, and DNS. Up to here I think it has been clear what is terraform and why we use it?

[Click & Read:–  Ansible playbook example with explanation ]

[Click & Read:–  Ansible ad hoc method in simple way for beginners]

Why we not use a configuration management tool?

As we discussed above, configuration management tools—like Puppet, Chef, and Ansible are excellent at managing applications and services. But they’re often focus on software configuration rather than building the infrastructure components that underpin our applications. Terraform is instead focus on building and deploying infrastructure.

This makes Terraform a very complementary tool in most organizations when building and deploying applications and infrastructure. We recommend using Terraform to build your infrastructure and then using your existing configuration management tools, with their pre-existing configuration stores, to configure your applications.

Why not Cloud Formation?

Many Cloud tools and SaaS services come with their own tools. An example is AWS Cloud Formation, which performs a similar function to Terraform, exclusively for AWS. Why not use one of these tools instead of Terraform? There are two big downsides to these tools. First, they (generally) only work for their own resources.

Second, also because they just provision their own infrastructure, these tools alone don’t necessarily make your environment fully functional. Some of these tools are best-of-breed for managing their own resources and don’t need to extend beyond that. In comparison, terrafrom provides a holistic solution that allows you to skip building that tool and limits the amount of infrastructure glue you need to create to manage resources from different services.

What is terraform and where we can you use it?

There are a wide variety of potential use cases of it. let’s discus one by one.

Multi-tier applications

Terraform is focus on infrastructure deployment and supports a diverse collection of components including compute, storage, and networking assets. This makes it ideal to build N-tier applications. It’s ideal for classic web applications with database backend right up to multi-tier applications with web, cache, application, middleware, and database tiers.

Production, development, and testing environments

Terraform, as your infrastructure is now codified. it’s easy to ensure that your production configuration can be shared with your development and testing environments to ensure consistency and compatibility.

Continuous delivery

This tool allows you to also codify your infrastructure. This means all of the pieces of your environment are now automatically deploy able, scalable, and manageable.

Managing your management tools

It can configure components like GitHub organizations and repositories, Pager Duty alerts, Grafana monitoring consoles, and DataDog metrics. This mean you can not only use this to build your infrastructure. But you can also start to codify the configuration of your management tools.

Conclusion –

I think everyone knows movement of IT industry towards automation. How fast IT industry is adopting automation tools for fast delivery and cost reduction. So, to learn automation tool for every DevOps engineers has become compulsion. That’s why in this tutorial we have discussed what is terraform and why we use it.

  Frequently asked interview Question 

  • What do you think can terraform replace Ansible, Puppet, Chef, Cloud Formation etc. tools?
  • How terraform works?
  • What are the major drawbacks of using this tools?
  • Can we perform configuration level task with the help of this tool?

///////////////////////


///////////////////////


///////////////////////


///////////////////////


///////////////////////


///////////////////////


///////////////////////


///////////////////////


///////////////////////


///////////////////////


///////////////////////

Comments