What is Infrastructure as Code? (IaC) and why do we need it in our lives?

What is Infrastructure as Code? (IaC) and why do we need it in our lives?

What is Infrastructure as Code?

infrastructure-as-code.png

Truth is infrastructure as Code (IaC) is amazing but why? Infrastructure as Code allows us to maintain one code base that can be deployed into various cloud platforms such as: Amazon's Web Services (AWS), Microsoft's Azure and Google Cloud Platform (GCP). The infrastructure can be managed in one single location which gives complete control over what services get spun up, what gets configured, what sequence do you want things to happen and how do you want them provisioned. It's AMAZING!

It gives complete control over your infrastructure pretty much, so why wouldn't you want to use infrastructure as Code? By using cloud agnostic tools such as Terraform & Chef, these tools can give you the powers of a super user. With a few commands you could spin up the same infrastructure on AWS / Azure / GCP. There are non-cloud agnostic tools like AWS Cloudformation that is dedicated to provisioning infrastructure within AWS accounts. It allows us to represent our AWS infrastructure in JSON or YAML configuration files that we can then execute to create, update, and destroy resources.

CloudFormation is very well integrated into the AWS ecosystem and has developed a lot of features for previewing, rolling back, and managing resource changes.

Terraform is my go-too Infrastructure as Code tool, here's why: Terraform is a cloud agnostic infrastructure provisioning tool. It allows us as developers to represent our infrastructure, regardless of whether it is AWS, Google Cloud or Azure, in a well-defined language known as HCL.

Terraform is highly extensible via plugins and has a very strong community around it that produces great open source modules for provisioning chunks of infrastructure.

Why use Infrastructure as Code?

To understand the Infrastructure as Code concept better, here is a brief explanation of how DevOps tasks were done (in the old days):

  1. before automation

  2. after automation

  • DevOps tasks BEFORE automation involved:

Before automation, things were fairly tough, we were doing everything by hand:

  1. setup servers
  2. configure networking
  3. install and configure software and applications
  4. etc

declarative-humor.jpeg

that doesn't even include the main tasks and processes needed to be setup and configured within our DEV, TEST and PROD environments.

  • DevOps tasks AFTER automation involved:

This is where Infrastructure as Code comes into play, it gives us the ability to automate all these DevOps tasks end-to-end automatically without having to do it manually (like in the old days).

All the knowledge and expertise of sys admins or DevOps engineers are packed into programs and applications that carry out those tasks effortlessly with little to no human error that would be associated with manual methods and tools.

Therefore, Infrastructure as Code (IaC) is a concept and there are infrastructure as Code tools, like Ansible, Puppet, Terraform or AWS Cloudformation, etc that can be used for different tasks and different use cases.

0_7XsPleNnQO0vIq2a.jpeg

Some less common but useful Infrastructure as Code (IaC) tools:

Yes we all know about the popular Terraform, AWS Cloudformation and let's not forget Ansible but there are also a few other tools that have their piece in the IaC pie, so let's shine some light on them shall we.

Chef

Chef falls under the configuration management tooling. It allows us to create recipes and cookbooks that define the exact steps needed to reach the necessary configuration of our application.

Chef, like Terraform, is cloud agnostic in nature. It uses the commonly known language, Ruby. Chef is typically used for configuring Elastic Compute (EC2) instances and even on-premises server. Very cool tool indeed!

Puppet

Puppet is another Ruby-based configuring management tool similar to Chef. The difference between the two is that Puppet is known as a declarative. tool. This means that we as developers define what our infrastructure is supposed to be and Puppet figured out how to make that true.

Juju

Juju is an IaC tool from Ubuntu (bet you didn't see that coming, I surely didn't) which allows developers to represent their infrastructure as charms which are a set of scripts that delay and operate systems. These charms can be packed together as bundles to deploy the entire infrastructure for an application.

Conclusion:

Lastly you must understand how Infrastructure as Code tools operate:

  • declarative vs procedural
  • mutable vs immutable
  • agent vs agentless

These factors play a key role in deciding which tools to use for which use cases given that there are certain criteria to be met.

Use this video as a beginners guide into Infrastructure as Code What is Infrastructure as Code by TechWorld with Nana

Use this video as a beginners - intermediate guide into Infrastructure as Code Infrastructure of Code

There are countless sources of good information about Infrastructure as Code and each individual tool but I leave that up to you to choose.

Thanks for tuning in and happy coding!