Table of contents
In the last blog, we learned about the configuration tool Ansible, and in this blog, we'll learn about the infrastructure provisioning tool Terraform.
What exactly is Terraform?
Let's say you decided to build a house and created a list of your desired features. The two most important items on the list will be the raw materials (infrastructure) and the people who can take the raw materials and organize (configure) them to build a home. Similar work is done by Terraform. It handles the infrastructure part.
Terraform, to put it simply, enables you to automate and manage the infrastructure.
Declarative
Terraform uses a declarative language. You might be unaware of the actual definition of declarative.
Because it is so straightforward, we provide the required state in our configuration file. Learn more about declarative and imperative language here.
Architecture
Terraform has 2 main components.
A) Core: It has two input sources.
Configuration file - where the user defines what to create (desired state)
State - It keeps track of all changes in an environment
core's job is to use these two inputs to plan how to get to the desired state specified in the configuration file. Core performs the necessary activity in generating, updating, and destroying after comparing the present state to the desired state.
B) Providers: Like AWS, Azure, Kubernetes ...etc. Terraform has more than 100 providers.
The core employs providers to carry out the plan after creating the execution based on the input file and state.
Commands
There are certain commands in Terraform that advance you through various levels.
refresh: It helps in getting the current state of the environment
terraform refresh
plan: It creates an execution plan
terraform plan -out plan.out
apply: It executes the plan
terraform apply plan.out
- destroy: It removes or destroys elements in the environment
terraform destroy --auto-approve
Please go through the list of a few commands that is given below.
Difference
Terraform: It is a tool for infrastructure provisioning.
Infrastructure refers to the devices and programs required to carry out a task, such as AWS, Docker, generating users, etc.
Ansible: It is a tool for configuring the infrastructure.
Configuration refers to a specific arrangement of the system and services.
That's all for now. Please like and share if you found this information informative. If you have any questions, please leave them in the comments section and I will do my best to answer them.
Thank you for reading, and I'll see you next time.