Day 60 - Terraform🔥
What is Terraform?
Terraform is an infrastructure as code (IaC) tool that allows you to create, manage, and update infrastructure resources such as virtual machines, networks, and storage in a repeatable, scalable, and automated way.
Task 1:
Installation of terraform
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install terraform
Task 2: Answering Questions
1. Why do we use Terraform?
- Terraform simplifies infrastructure management by allowing us to define our infrastructure as code. It enables automation, consistency, and scalability while reducing manual error-prone processes.
2. What is Infrastructure as Code (IaC)?
- IaC is a practice of managing and provisioning computing infrastructure through machine-readable script files rather than physical hardware configuration or interactive configuration tools.
3. What is a Resource in Terraform?
- In Terraform, a resource is a virtual representation of any infrastructure component, such as a network interface, an EC2 instance, S3 bucket, dynamodb table, or a security group.
4. What is a Provider in Terraform?
- A Provider in Terraform is responsible for interacting with APIs and managing resources. It defines and configures the infrastructure elements. For example, AWS, Azure, or Google Cloud can be providers in Terraform.
5. What is the State file in Terraform, and why is it important?
- The State file is a crucial component in Terraform. It stores the current state of the infrastructure managed by Terraform. It helps Terraform understand what has been deployed and track changes in configuration. This file is vital for collaboration, avoiding conflicts, and enabling Terraform to plan and execute changes accurately.
6. What is Desired and Current State in Terraform?
- Desired State refers to the configuration you define in your Terraform files, specifying how you want your infrastructure to be. Current State is the actual state of the deployed infrastructure tracked by Terraform after applying the configuration. Terraform continuously works to make the current state match the desired state.