Hi there, It's Dilan 🤓!
In this first episode of the blog series, we will be taking a look at what's Terraform by going through the following topics:
- What's DevOps?
- What's Infrastructure as Code or IaC for short?
- How Terraform works
- A little Comparison with other IaC
What's DevOps
DevOps for 'Development and Operations' comes from the fact that in the past to build softwares, we had two separate teams: One for development of the actual software or product which focus on coding the application and making it run on their machine, and the other team called the 'Operations Team' which was responsible for taking the finished software and manually deploying it on servers (which is as you can see time-consuming and is more open to anomalies and errors). With the rise of Cloud Computing
, it became easier to manage servers since now even the Operations team was using software, but that brought confusion. If the Operations and Development are using Software where is the point of separating them? Also when they are separated the Operations team touch the software at its very end when it's time to deploy, meaning that when the Development team is working on the software, the Operations team is literally doing nothing thus wasting time.
The concept of DevOps came to solve those issues, by proposing a new way of building software which a more circular way and involves the deployment at each incremental step of the software leading to a more robust and error-free software.
There are four (04) core values of DevOps abbreviated as the acronym CAMS
:
- Culture
- Automation 🤖
- Measurement 📏
- Sharing 🤝
The one that resonates with our series on Terraform
is Automation
which is the process of using code to manage all the servers and infrastructure instead of manually doing it or clicking around on buttons. That automation concept is what we call Infrastructure as Code
or IaC for short.
What's Infrastructure as Code or Iac for short?
The whole picture here is as follows:
You have one file where you write all the code describing your infrastructure and all the services that you will need to run your application on a cloud environment (like AWS, Azure, and or GPC). This file is read by a tool that will take care of deploying all the resources, services where it should be deployed on the cloud for you. This is what we call Infrastructure as Code
.
They are four broad categories of IaC tools:
- ad Hoc Scripts : Great for small one-off tasks, but not for managing large infrastructure
- Configuration Management tools: Give a more structured and organized way of managing large infrastructure
- Server templating tools : Completely create an image of a server that captures a fully self-contained 'snapshot' of the OS, the software, files, and all other relevant details.
- Server provisioning tools : They are used to create servers, databases, caches, load balancers, and a lot more. They are the most used tools in the IaC world.
Talking of images :
A little Comparison with other IaC
Example of a Terraform code that creates an AWS instance:
How Terraform works ?
Terraform is an open-source tool created by HashiCorp and written in the Go Programming language. It is used to build, change, and version infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.Here is how Terraform works in a nutshell:
-
You write the code that describes your infrastructure in a file with a
.tf
extension, this file is thecode
part of theInfrastructure as Code
. You can define your entire infrastructure in a single file or split it into multiple files. -
You run
terraform init
to initialize the working directory containing the Terraform configuration files -
You run
terraform plan
to create an execution plan -
You run
terraform apply
to apply the changes required to reach the desired state of the configuration
What happens is that the terraform code you write is converted into a single or multiple binary codes which under the hood is calling API of well-known cloud providers (like AWS, Azure, GCP) to create the resources you defined in your code.
When someone in your team wants to change something in the infrastructure, they can do so by changing the code inside the terraform configuration file, validate the changes and test it through automated tests and code reviews, and then apply the changes to the infrastructure with the terraform apply
command.
A little Comparaison with other IaC
Feature/Tool | Terraform | AWS CloudFormation | Azure Resource Manager (ARM) Templates | Google Cloud Deployment Manager |
---|---|---|---|---|
Multi-Cloud Support | Yes | No (AWS only) | No (Azure only) | No (Google Cloud only) |
Declarative Syntax | Yes | Yes | Yes | Yes |
State Management | Yes (Remote and Local) | No (Managed by AWS) | No (Managed by Azure) | No (Managed by Google Cloud) |
Modularity and Reusability | High (Modules and Providers) | Medium (Nested Stacks) | Medium (Linked Templates) | Medium (Templates and Types) |
Community and Ecosystem | Large (Extensive Modules and Providers) | Medium (AWS-specific) | Medium (Azure-specific) | Medium (Google Cloud-specific) |
Third-Party Integrations | Extensive (Supports many third-party services) | Limited (AWS services and some third-party) | Limited (Azure services and some third-party) | Limited (Google Cloud services and some third-party) |
Learning Curve | Moderate | Low (AWS users) | Low (Azure users) | Low (Google Cloud users) |
Preferred for | Multi-cloud, hybrid cloud, and complex setups | AWS-specific infrastructure | Azure-specific infrastructure | Google Cloud-specific infrastructure |
It was Dilan, GDGoC ( Google Developer Groups On Campus) Lead. See you soon! 👋