# 1. Overview

### Introduction

* Terraform is tool for building, changing, and versioning infrastructure safely and efficiently
* It enables application software best practices to infrastructure
* Compatible with many clouds and services
* Written in hashicorp configuration language in a file that has **.tf** extension

***

### Architecture

<figure><img src="https://1920086362-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDfv51K0WXLZdwTryHQZc%2Fuploads%2FWN9TETVwEXXP7boyskuA%2Fimage.png?alt=media&#x26;token=b93f0d82-7354-4966-8986-93ded3e2eefb" alt=""><figcaption></figcaption></figure>

### Providers

* It is a plugin that allows us to talk to set of APIs
* For instance, to interact with AWS, we have to download the AWS provider
* Similarly, in order to interact with Kubernetes, we have to download the Kubernetes provider

***

### Data

* Used to reference the existing resources in the cloud

***

### Basic Commands

1. `terraform init` - looks for all the providers in all config files in current directory and downloads the necessary plugins
2. `terraform plan` - does a dry run of your code
3. `terraform apply` - to run our code

***

### Sample Activity Code

```hcl
#####################
# Setting up provider
# Hard coded autentication credentials, non recommended way
#####################
provider "aws" {
  region = "us-east-1"
  access_key = "<access_key>"
  secret_key = "<secret_key>"
}

#####################
# Making a resource
# Same syntax for every provider
#
# resource "<provider>_<resource_type>" "name" {
#   config options.....
#   key = "value"
# }
#####################

#####################
# Deploying EC2 Instance
#####################
resource "aws_instance" "my-first-server" {
    ami = "ami-052efd3df9dad4825"
    instance_type = "t2.micro"

```


---

# Agent Instructions: 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:

```
GET https://notes.nomanaziz.me/devops/infrastructure-as-a-code-iac/terraform/1.-overview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
