Table of contents
🙏 Introduction:
In this blog, we will go deep dive into Terraform & Install Terraform on our system .
🔶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 this link for installation
- Create an EC2 instance
Visit the Terraform website's official download page at https://www.terraform.io/downloads.html to download the right package for your system.
Choose Ubuntu as the package manager
Copy the commands & run into the instance terminal.
- Check the Terraform version
terraform -version
🎯Task: 2
Why do we use terraform?
We use Terraform to make it easier to manage and automate the process of setting up and maintaining our computer infrastructure. Imagine you have a bunch of computers, servers, and other resources that you need to set up for your application or business. Doing this manually can be time-consuming and error-prone.
Terraform allows you to describe your desired infrastructure in a simple configuration file. You specify what resources you need (like servers, databases, and networks) and how they should be configured. Then, Terraform takes care of actually creating and managing those resources for you.
The key benefits of using Terraform include:
Automation: Terraform automates the provisioning and configuration of infrastructure, saving time and reducing the chance of human error.
Consistency: With Terraform, you can ensure that your infrastructure is set up consistently every time, which helps avoid issues caused by differences between environments.
Versioning: You can version control your infrastructure code using Terraform, making it easier to track changes, roll back to previous states, and collaborate with others.
Scalability: Terraform makes it easier to scale your infrastructure up or down based on your needs, whether you're dealing with a small project or a large enterprise.
In summary, Terraform simplifies and automates the process of managing infrastructure, making it more efficient, consistent, and scalable.
What is Infrastructure as Code (IaC)?
Infrastructure as Code (IaC) means writing code to manage and automate the setup, configuration, and maintenance of computer infrastructure. Instead of manually setting up servers, networks, and other resources, you use code to define how your infrastructure should look and behave.
Here are some key points to understand about Infrastructure as Code:
Code for Infrastructure: With IaC, you express your infrastructure needs using a programming language or a configuration file. This code describes what resources you want (like servers, databases, and storage), how they should be configured, and how they should interact.
Automation: The code you write is used to automate the process of provisioning and managing your infrastructure. This automation reduces manual effort, speeds up the setup process, and minimizes the chance of human error.
Consistency: IaC helps ensure that your infrastructure is consistent across different environments (like development, testing, and production). This consistency helps avoid issues caused by differences in configurations.
Version Control: Infrastructure code can be versioned using tools like Git. This means you can track changes to your infrastructure over time, roll back to previous states if needed, and collaborate with others effectively.
Scalability: IaC makes it easier to scale your infrastructure up or down based on your needs. You can modify your code to add or remove resources, making it adaptable to changing requirements.
In summary, Infrastructure as Code is about treating your infrastructure setup as code, using programming principles to automate and manage it efficiently. This approach brings benefits such as automation, consistency, version control, and scalability to the process of handling computer infrastructure.
What is a Resource?
In Terraform, a resource refers to a specific infrastructure component or service that you want to manage. It represents an entity that Terraform can create, modify, or destroy to provision and manage your infrastructure. Resources can include virtual machines, storage containers, network interfaces, databases, load balancers, DNS records, and more.
What is Provider?
In Terraform, a provider is a plugin that acts as an interface between Terraform and a specific cloud platform, service, or infrastructure technology. Providers are responsible for managing the lifecycle of resources and handling interactions with the underlying APIs or infrastructure services.
What is a State file in Terraform? What’s the importance of it?
In Terraform, a state file is a JSON-formatted file that keeps track of the current state of your infrastructure. It records the metadata and attributes of the resources managed by Terraform, including their dependencies and relationships. The state file is created and updated by Terraform during the execution of terraform apply
or terraform import
commands.
What is Desired and Current State?
In Terraform, the desired state refers to the configuration that you have defined in your Terraform files (*.tf) to describe the infrastructure resources you want to create and manage. It represents the ideal or intended state of your infrastructure. The desired state is defined in terms of resource types, attributes, dependencies, and other configurations.
On the other hand, the current state refers to the actual state of your infrastructure resources as tracked and recorded in the Terraform state file. It reflects the current state of the resources provisioned by Terraform, including their attributes, relationships, and dependencies. The current state is updated and managed by Terraform during the execution of the terraform apply
or terraform import
commands.
👋 Conclusion :
In this blog, we have Terraform basics & install Terraform on our EC2 instance. We will cover advanced topics in a future post.
Thank you for reading!
Contact me on Linkedin
Check out my GitHub for more resources 📚