Table of contents
What Is Terraform
To understand Terraform, let's step back a little to understand what infrastructure as code (IAC) means
What Is Infrastructure As Code (IAC)
What is Infrastructure as code IAC, to better understand this, let's break down two important Words in infrastructure as code (IAC), which are Infrastructure and Code
- Infrastructure: the simplest way to see this is by taking it with its Literal meaning,
Infrastructure,
what isinfrastructure
- infrastructure Refers to Buildings, structures, etc. things built with Concrete or Irons, that either help to provide coverage (hotels, Banks, stadiums) or Access (bridges, Train Tracks), basically when you think of infrastructure, images like this might come to mind
Now, let's Relate this To the Infrastructure in the cloud, Infrastructure in the cloud relates to Huge buildings(Data centers), which hold Huge computers i.e servers, and the cloud Provider (AWS, Azure, GCP), lets you (users), rent these servers to either host applications or Perform any Operations you want to do with a computer.
Code: Code is simply put syntax, we use to write software so for example, we can have a codebase written in javascript, python or Ruby e.t.c
Here is an example of a code snippet in javascript
Now IAC is basically some set of principles, that combines writing code to deploy Infrastructure, so I can Write code in Maybe Javascript and create An EC2 instance(web server) in the AWS cloud, for example.
But a next Valid Question that may come in is why would you do that, why not log in to the AWS console and Create an EC2 instance, if am not a programmer why should I go through the whole process of Learning a programming language just to deploy my Infrastructure?
let's Answer these questions in two steps
With Tools like Terraform, it enables us to take Best Practices from software development, and Apply them to our infrastructure, things such as
Git - git is a version control system that enables several people to work on the same project, it helps reduces error via reviews (pull requests), and keep track of previous changes made on the codebase, so with IAC, we can introduce the development of our infrastructure to with code in the Terraform configuration language, or YAML if you are using another service like cloud formation, to keep track of who did what and when.
so when a junior DevOps person is hired in our team, we can evaluate and validate his configuration before merging it into Production.
The concern of you Learning a programming Language to do IAC is not required, in fact, mostly you will have Infrastructure provisioned in configuration languages like YAML or JSON, but terraform does have its syntax, which I find more initiative and easier
Now Having understood these two concepts let's talk about Terraform.
What is Terraform
Terraform is an IAC tool, that is used to provision Infrastructure in the cloud, the Best Part being, you can provision for any cloud, be it AWS, GCP, or Azure, using the same configuration language terraform.
Terraform is Declarative
Terraform is a declarative way of doing IAC, which means we just say what we want, and not how we want to achieve what we want, an Example would help.
Let's say I want to provision an EC2 instance in AWS with terraform, ill just say I need the following
A t2.micro type of instance, with 2VCPU and 20GB of storage
Terraform then provisions, that instance for you.
In an Imperative Approach, you specify how the instance would be provisioned, and an example of this is a tool like Ansible
Other IAC Tools
Terraform is just one in the list of IAC tools, some are general while others are platform specific, others might not be considered as IAC tools, but since they all involve automation.
below are some examples
CloudFormation - This is a Platform Specific IAC Tool, in the AWS cloud, for Provisioning and Running configurations.
Azure Resource Manager - Azure-specific tool, used to deploy resources in the Azure cloud
Google Cloud Deployment Manager - Google Cloud Tool for doing IAC
Ansible - This is used mostly, to provision servers on run-specific configurations, after or when the server is been created.
Pulumi - This Helps you to write code to deploy your infrastructure, this is generally for developers who are familiar with a specific programming language
Puppet
Chef
Thanks for your Time.
You can reach out to me via
Would Love to hear your concerns and suggestions
Read part two here - https://hashnode.com/post/clficusht000q09ldc9gi9dyn