Day 60 - Terraform🔥

Day 60 - Terraform🔥

·

2 min read

Hello Learners , you guys are doing every task by creating an ec2 instance (mostly). Today let’s automate this process . How to do it ? Well Terraform is the solution .

What is Terraform?

  • Terraform is an Infrastructure as Code (IaC) tool that allows you to manage infrastructure resources like virtual machines, networks, and storage in a scalable, repeatable, and automated manner.

Task 1: Installation of terraform

  • To get started with Terraform, follow these steps for installation:
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common
wget -O- https://apt.releases.hashicorp.com/gpg | \
gpg --dearmor | \
sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
gpg --no-default-keyring \
--keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg \
--fingerprint
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-get install terraform -y && terraform --version

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.

I Hope this blog will help you understand how to write a basic Terraform configuration details and basic commands on Terraform.


Happy Learning

Thanks For Reading! :)

-SriParthu💝💥