# DevOps (Day: 60) Terraform Infrastructure as a code

### Task-01

**Install Terraform on your System (AWS).**

### Task-02

### Various Answers in Terraform:- IAC,Resources, Providers,state file & Desired and Current state.

***Terraform Architecture***

![No alt text provided for this image](https://media.licdn.com/dms/image/D4D12AQED-m0szG6ptg/article-inline_image-shrink_1500_2232/0/1686335248388?e=1720051200&v=beta&t=sX3Yvo6Ui2gZ6rhN5L9Adlj90YWYgguuuaCJxTEErGI align="left")

Terraform Architecture Diagram.

***What is Terraform?***

![No alt text provided for this image](https://media.licdn.com/dms/image/D4D12AQEx6DXuc1LUYQ/article-inline_image-shrink_1500_2232/0/1686335455254?e=1720051200&v=beta&t=HRf5ZptjV2QM1f8K9QIAxPRHA-LzOMs3wCzy6Vr4GvA align="left")

***Terraform is an infrastructure as code (IAC) tool that allows you to create the manage, and update infrastructure resources such as virtual machines, networks and storage in a repeatable,scalable and automated way.***

### Task-01

***Install the Terraform on your system:***

***Create an EC2 intance.***

![No alt text provided for this image](https://media.licdn.com/dms/image/D4D12AQHsK5ZjUdvDQA/article-inline_image-shrink_1500_2232/0/1686458091183?e=1720051200&v=beta&t=4LXcbKmFTy6FEWJ_QY2gGcmFaP1ft971wvANRZcc7gk align="left")

Create an EC2 intance Diagram.

***Now SSH into you ubuntu EC2 instance.***

![No alt text provided for this image](https://media.licdn.com/dms/image/D4D12AQFAm6stcx7mJg/article-inline_image-shrink_1500_2232/0/1686458117858?e=1720051200&v=beta&t=Onn12YJSYEt932mF0YhDGzLVfJh4USr_Fp_w1hbFjoY align="left")

Now SSH into you ubuntu EC2 instance Diagram.

***Download the appropriate package for your system form the offical Terraform website*** ([https://www.terraform.io/downloads.html](https://www.terraform.io/downloads.html)).

**Select the Linux as the operating system and ubuntu as the package manager.**

**Copy and paste below 3 Commands to instance terminal, you can direct copy here:-**

![No alt text provided for this image](https://media.licdn.com/dms/image/D4D12AQHQwkqdr9nUPg/article-inline_image-shrink_1500_2232/0/1686458169998?e=1720051200&v=beta&t=6-O3Egkm4FJCjxmjrGwTLbE2aQxRyqpxAqpUP_q1U20 align="left")

Copy and paste below 3 Commands to instance terminal, you can direct copy here Diagram.

***Install Terraform by running the following command:***

![No alt text provided for this image](https://media.licdn.com/dms/image/D4D12AQEZP0W1_ARiVw/article-inline_image-shrink_1500_2232/0/1686458213286?e=1720051200&v=beta&t=UY2QXYkwsaF4CGE-EaniSfJg_mEZBd4PkLmg27INh5M align="left")

Install Terraform by running the following command Diagram.

![No alt text provided for this image](https://media.licdn.com/dms/image/D4D12AQGVJvLA1SD6Rw/article-inline_image-shrink_1500_2232/0/1686458229721?e=1720051200&v=beta&t=e6hXrt-VgcQkDP9rXodfNsVwE1Hm6PRnqmr8UGW6Uvg align="left")

Install Terraform by running the following command Diagram.

***Verify the Terraform is installed correctly by running the following command:***

```bash
terraform --version
```

![No alt text provided for this image](https://media.licdn.com/dms/image/D4D12AQGhh6u7BvUEtQ/article-inline_image-shrink_1500_2232/0/1686458253961?e=1720051200&v=beta&t=4tIv9aLJ58Wbwnp6J1dcfipmScRraOYYaQK4qs4LgNg align="left")

Verify the Terraform is installed correctly by running the following command Diagram.

### Task -02

**Answer the below questions.**

**Why we use Terraform?**

**Terraform is a tool for building.changing and versioning infrastructure in a safe,repeatable way. It enables teams to manage infrastructure as code, providing a single resource of truth for the instance and ensuring that it is always in the desired state. Terraform can be used to manage infrastructure across multiple cloud providers and on premises infrastructure, and its supports a wide range of resource types.**

![No alt text provided for this image](https://media.licdn.com/dms/image/D4D12AQHqOKtOt4EFeg/article-inline_image-shrink_1500_2232/0/1686336338465?e=1720051200&v=beta&t=NS1THXELy8wi7YlcrWU0ME0cKe-l9INJ0QYEhXlfZ-M align="left")

Why we use Terraform Diagram.

***What is Infrastructure as a Code (IAC)?***

***Infrastructure as Code (IAC) is a practice of managing and provisioning infrastructure using code instead of manual processes. By treating infrastructure as code, teams can version control their infrastructure, automate the provisioning and improve collabration between different teams. IAC enables teams to make changes to infrastructure in a safe and repeatable way, and it helps to reduce the risk of human error and inconsistencies.***

![No alt text provided for this image](https://media.licdn.com/dms/image/D4D12AQGpE6wTNjDLJw/article-inline_image-shrink_1500_2232/0/1686336782861?e=1720051200&v=beta&t=9TKCTQM52owy4BywSjmLLg8pEPajpKF4-n1qMgTBhSg align="left")

What is Infrastructure as a Code (IAC) Diagram.

**What is Resources?**

**In Terraform, a resource is a declarative representation of a component in a cloud infrastructure, such as a virtual machine, database, or network interface. Resources define the desired state of the component, and Terraform uses the resource definition to create, modify, or delete the component as needed.**

![No alt text provided for this image](https://media.licdn.com/dms/image/D4D12AQHV19AVHadtkQ/article-inline_image-shrink_1500_2232/0/1686337040798?e=1720051200&v=beta&t=ngbolm4YBWrTL_2mFlwYzo_WbWCJ4lGKiCcK0SycSzQ align="left")

What is Resources Diagram.

**What is Provider?**

**In Terraform, a provider is a plugin that interfaces with a specific cloud infrastructure provider or service. Providers define the resources that Terraform can manage, as well as the methods for creating, updating, and deleting those resources. Examples of providers include AWS, Google Cloud, and Microsoft Azure.**

![No alt text provided for this image](https://media.licdn.com/dms/image/D4D12AQEz2f-Fu2a0lQ/article-inline_image-shrink_1000_1488/0/1686458372395?e=1720051200&v=beta&t=xIxPXjPJmLs7_rKNiDUyaQW2gurZuMumJjaasK4ncV0 align="left")

What is Provider Diagram.

**What is State file in terraform? What is the importance of it?**

**The Terraform state file is a json file that stores the state of the infrastructure managed by Terraform. it includes information about the resource that have been created their current state and any deployment between them, The state file is critical to Terraform operations as it is used to plan and execute changes to the infrastructure.**

![No alt text provided for this image](https://media.licdn.com/dms/image/D4D12AQGgWzLXgmR8QA/article-inline_image-shrink_1500_2232/0/1686337575206?e=1720051200&v=beta&t=Oqe-s44FO6qMLtUApA_E2XVeuq9QUvnN2X2IxE-dBD4 align="left")

What is State file in terraform? What is the importance of it Diagram.

**What is Desired and Current State?**

**In Terraform, the desired state is the state that you want your infrastructure to be as defined in your Terraform Configuration files. The current state is the actual state of the infrastructure as represented in the Terraform state file. When you run the Terraform apply . Terraform compares the desired state with the current state and makes changes as needed to bring the infrastructure into the desired state.**

*Thank you for reading!!* Hope you find this helpful.

#day60challenge#90daysofdevops

Always open to suggestions..!!

~ Manoj Bhamidipati 🙂
