> For the complete documentation index, see [llms.txt](https://notes.nomanaziz.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.nomanaziz.me/devops/infrastructure-as-a-code-iac.md).

# Infrastructure as a Code (IaC)

### Categories

1. Ad hoc scripts
   * Shell script that makes calls to like AWS to provison 5 EC2 machines
2. Configuration management tools
   * Used on premis to manage config of servers
   * Ansible, puppet and chef are examples
3. Server Templating tools
   * Used for building out a template will be provisioned on a server
   * Examples are Amazon AMI
4. Orchestration tools
   * Kubernetes is an example
5. Provisioning tools
   * Used to provision cloud resources

***

### Declarative vs Imperative

#### Declarative

* We define end state of what we want
* Tool manages what API calls need to be made and it makes that happen

#### Imperative

* We tell system what we want to happen and the **sequence** in which we want to happen

***

### Cloud Specific vs Cloud Agnostic

#### Cloud Specific

* Examples are AWS Cloud Formation, Azure Resource Manager, Coogle Cloud Deployment Manager which focuses on particular cloud

#### Cloud Agnotic

* It does not focus on a simple platform. It is generic in nature
* Examples are Terraform and Pulumi

***

### Common Patterns

#### Provisioning + Config Management

We can use terraform with ansible, chef or puppet that will allow us to for instance setup a particular service once EC2 machine is deployed

#### Provisioning + Server Templating

Terraform can also be used with hashicorp packer which package the image and can be used later as an AMI

#### Provisioning + Orchestration

Terraform can be used with kubernetes cluster. Terraform is used to deploy cloud resources and k8 will be used to deploy the applications managed onto that cloud resource

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://notes.nomanaziz.me/devops/infrastructure-as-a-code-iac.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
