🔶 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: Install Terraform on your system Refer to this link for installation
Prequistis makes an EC2 instance and connects it.
#First of all update the system
sudo apt update -y
#Install docker
sudo apt install docker.io -y
#check docker version
docker -v
#Docker version 24.0.5, build 24.0.5-0ubuntu1~22.04.1
To install Terraform, perform a Google search for 'Terraform install' and then select 'Linux -> Ubuntu' Use this link.
#step 1
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common
#step 2
wget -O- https://apt.releases.hashicorp.com/gpg | \
gpg --dearmor | \
sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
#step 3
gpg --no-default-keyring \
--keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg \
--fingerprint
#step 4
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
#now update your system
sudo apt update
#Install terraform
sudo apt-get install terraform
#To check terraform version
terraform -v
🔶 Task 2: Answer the below questions
Why do we use terraform?
Terraform allows you to build, change, and version your infrastructure using code techniques.Terraform simplifies infrastructure provisioning by automating and standardizing the process, making it more reliable, efficient, and consistent. It aligns with modern DevOps practices and supports the dynamic nature of cloud and hybrid cloud environments.
What is Infrastructure as Code (IaC)?
Infrastructure as Code (IaC) is an approach to managing and provisioning computer data centers, cloud resources, and IT infrastructure through machine-readable, descriptive files, rather than physical hardware configuration or interactive configuration tools.
What is a Resource?
Defines and provisions infrastructure objects within a provider.resource "aws_instance" "example" { ami = "ami-0c55b159cbfafe1f0" instance_type = "t2.micro" }
What is a Provider?
Manages resources in a specific cloud or infrastructure platform.provider "aws" { region = "us-east-1" }
What is a State file in Terraform? What’s the importance of it?
Terraform state is essential for managing infrastructure efficiently. It tracks resources, resolves dependencies, and syncs infrastructure with your configuration. It enables concurrency control, rollbacks, and stores output information. For teams, it supports remote collaboration and versioning. Overall, it maintains infrastructure as code integrity.
What is the Desired and Current State?
Desired State: The desired state is the state you specify in your Terraform configuration files (typically written in HashiCorp Configuration Language or HCL). It represents the infrastructure configuration you want to achieve.Current State: Definition: The current state is the actual state of your infrastructure as tracked by Terraform. It reflects the real-world state of your resources based on the last Terraform run.
We Hope this task will help you understand how to write a basic Terraform configuration file and basic commands on Terraform.
Happy Learning :)
Stay in the loop with my latest insights and articles on cloud ☁️ and DevOps ♾️ by following me on Hashnode, LinkedIn (https://www.linkedin.com/in/chandreshpatle28/), and GitHub (https://github.com/Chandreshpatle28).
Thank you for reading! Your support means the world to me. Let's keep learning, growing, and making a positive impact in the tech world together.
#Git #Linux Devops #Devopscommunity #90daysofdevopschallenge #python #docker #Jenkins #Kubernetes