Explain IaC like I'm Five
Tags: iac, devops, sre, beginners
Published: 2020-07-19 03:35:03

| IaC like I'm Five  | 
| ------------- | 
| [ What is Infrastructure as Code](#Iac) | 
| [ Why should we use it](#why)|
| [ How do we use it](#how)|
| [ Terraform Example](#tf)|
| [ Other IaC Tools](#other)|
-------------------


## What is Infrastructure as Code? <a name="Iac"></a> 

Historically, creating infrastructure involved manually setting up servers and configuring systems to run applications, operating systems, databases...etc. Infrastructure was imperatively configured and maintained, meaning this was done with step by step instructions and executed by the admin. This process becomes unsustainable with large & complex systems leaving room for ***issues with cost, availability, and consistency***. 

Infrastructure as Code solves these problems by ***automating setup and management*** by writing code in a high-level descriptive language.   

![Alt text of image](https://res.cloudinary.com/dssijnlrx/image/upload/v1595066847/tf2_qklm1n.png)
<figcaption>With Iac we can produce secure,reliable, and robust infrastructure</figcaption>

---------------------------


HashiCorp's Founder, [Armon Dadgar](https://twitter.com/armon) explains IaC simply and eloquently in this short video
{% youtube RO7VcUAsf-I %}

-----------------

## Why should we use it? <a name="why"></a> 

![Alt text of image](https://media.giphy.com/media/26xBF35LZZva64nuw/giphy.gif)

Accidents happen, ***human error*** happens. By automating infrastructure with code we reduce error and produce more reliable code.

***Complexity***, with the emergence of cloud-based infrastructure IaC is paramount for scaling distributed systems, cloud-native applications, and service-based architecture. 

---------------------

## How do we use it? <a name="how"></a> 

{% youtube zWw2wuiKd5o %}
<figcaption>Sai Vennam with IBM Cloud discusses approaches to IaC with a quick example</figcaption>

----------------------

#### Terraform Example <a name="tf"></a>

[Terraform](https://www.terraform.io/) is a cloud provider agnostic orchestration tool. This means we can build, version, and destroy resources across multiple providers at the same time. We can also easily look up modules to use directly from the [Terraform Registry](https://registry.terraform.io/) saving time on creating common configurations. These features make it a leader in IaC. Now let's take a look at the power of Terraform with an example.

![Alt text of image](https://res.cloudinary.com/dssijnlrx/image/upload/v1595124343/carbon_6_emthqa.png)
<figcaption>This is a Terraform module which creates a private S3 bucket resource on AWS with versioning enabled in HCL(HashiCorps's configuration language)
</figcaption>

#### Other IaC Tools <a name="other"></a>

Another Orchestration tool is [***AWS CloudFormation***](https://aws.amazon.com/cloudformation/), this tool is similar to Terraform but it is only AWS focused.

Along with orchestration tools, there are configuration management tools. They are used to install and manage software on existing servers. 

Common configuration management tools:

  * [Ansible](https://www.ansible.com/resources/get-started)
  * [Puppet](https://puppet.com/) 
  * [SaltStack](https://www.saltstack.com/) 
  * [Chef](https://www.chef.io/products/chef-infra/)

** Some configuration management tools can be used for orchestration. It all depends on the best fit for your needs or the task.