I would like to list my terraform day 1 learnings along with the detailed explanations of all the points.
- Terraform is an open source infrastructure as a code tool used to build infrastructure on cloud.
- We can create resources in multiple clouds using terraform. It uses declarative language.
- It is a tool developed by HashiCorp and it uses HashiCorp Configuration Language.
Terraform is widely used because of the following reasons:
- It helps to implement multi cloud strategy.
- It is time saving.
- The code is reusable in nature.
- Build on-premises infrastructure using terraform.
- It is used widely in deployment services.
- It is idempotent in nature i.e If there is one resource which is already installed, it will not install it again(which means it won't actually change anything).
- Automate infrastructure on any cloud.
HOW DOES TERRAFORM WORKS?
- Terraform creates and manages resources using the concept of Application Programming Interface(API).
- Terraform takes an immutable approach to infrastructure, reducing the complexity of upgrading or modifying the infrastructure.
- The following commands are widely used in terraform:
a. write-> Write the code and define the resources.
b. plan-> Check what is being created.
c. Apply-> Approval for performing the code in the correct order.
DIFFERENCE BETWEEN TERRAFORM AND ANSIBLE:
- BASED ON TYPE: Ansible is a configuration management tool whereas Terraform is a orchestration tool which is used to create and manage resources.
- BASED ON INFRASTRUCTURE: Ansible provides support for mutable infrastructure whereas Terraform supports immutable infrastructure.
- BASED ON LANGUAGE: Ansible follows a mixture of procedural and declarative languages(Define all the steps) whereas Terraform is based on declarative language.
- BASED ON PACKAGING AND TEMPLATING: Ansible provides complete support for packaging and templating whereas Terraform provides partial support for packaging and templating.
- BASED ON LIFECYCLE MANAGEMENT: Ansible does not have lifecycle management whereas Terraform is heavily dependent on lifecyle or state management.