# Infrastructure as Code - Terraform

There are two people working in the same company. One is **Vijay** who is working as Cloud Architect in that organisation . Another person is **Veera** who joined as fresher in that same Organisation . He is interesting to learn the Cloud & Devops concepts and improve his skills in that field

One day, Veera spoke with Vijay for clarifing his doubts in Infrastructure as Code (IAC)

their conversation would be like this,

**Veera**  : Hi Vijay. Hope you are doing well. 

**Vijay**  : I'm good. Thanks for asking. How are you ?. How is your day going on ?

**Veera** : I'm good. It's going well

**Veera** :  I have some doubts in IaC. Can you please explain ?

**Vijay** : Sure. Please share . Let us discuss

**Veera** :  **what is Infrastructure as Code or IAC  ? ** 

**Vijay** :  IAC or Infrastructure as Code allows you to build, change, and manage your infrastructure through coding instead of manual processes. The configuration files are created according to your infrastructure specifications and these configurations can be edited and distributed securely within an organization.

**Veera** : ** What is Terraform ?** 

**Vijay** : Terraform is an infrastructure as code tool that lets you build, change and version cloud and on-prem resources safely and efficiently

**Veera** :  ** What are the advantages of using Terraform ? ** 

**Vijay** :
- Open Source
- Uniform Syntax for Infrastructure as Code
- Support of various cloud solutions
- Highly expandable
- Storage and import function for existing architectures
- Ability to generate dependency graphs

**Veera** : ** What are the  disadvantages of Terraform ? **

**Vijay** :

- No automatic rollback function for incorrect changes to resources
- Collaboration and security features available only in expensive enterprise plans



**Veera** :  ** How to setup development environment ?**

**Vijay** : please check this link  [Terraform setup ](https://learn.hashicorp.com/tutorials/terraform/install-cli)


**Veera** : ** What are the basic commenly used commands ? **

```
terraform init

```
**Veera** : ** What is terraform init ? ** 

**Vijay** :

It is  used to initialize a working directory containing Terraform configuration files. This is the first command that should be run after writing a new Terraform configuration or cloning an existing one from version control. It is safe to run this command multiple times.


```
terraform plan

```
**Veera** :  **What is terraform plan ? **

 **Vijay** : It creates an execution plan, which lets you preview the changes that Terraform plans to make to your infrastructure


```
terraform apply

```
**Veera** :  **What is terraform apply ?**

 **Vijay** : It performs a plan just like terraform plan does, but then actually carries out the planned changes to each resource using the relevant infrastructure provider's API

```
terraform destory

```

**Veera** :  ** What is terraform destory ? **

**Vijay** : The terraform destroy command is a convenient way to destroy all remote objects managed by a particular Terraform configuration.

```
terraform refersh

```
**Veera** :  **What is terraform refersh ? ** 

**Vijay** :  The terraform refresh command reads the current settings from all managed remote objects and updates the Terraform state to match. But This command is deprecated, because its default behavior is unsafe if you have misconfigured credentials for any of your providers.

```
terraform validate

```
**Veera** :  **What is terraform validate ? **

**Vijay** : The terraform validate command validates the configuration files in a directory, referring only to the configuration and not accessing any remote services such as remote state, provider APIs, etc


```
terraform show

```

**Veera** :  **What is terraform show ? **

**Vijay** :  The terraform show command is used to provide human-readable output from a state or plan file. This can be used to inspect a plan to ensure that the planned operations are expected, or to inspect the current state as Terraform sees it.


```
terraform fmt

```
**Veera** :  ** What is terraform fmt ?**

**Vijay** :  The terraform fmt command is used to rewrite Terraform configuration files to a canonical format and style


```
terraform state

```

**Veera** :  ** What is terraform state ? ** 

**Vijay** :
The terraform state command is used for advanced state management. As your Terraform usage becomes more advanced, there are some cases where you may need to modify the Terraform state. Rather than modify the state directly, the terraform state commands can be used in many cases instead

```
terraform workspace

```
**Veera** :  ** What is terraform workspace ?**

**Vijay** :
A workspace is everything Terraform needs to run: a configuration file, input variables, and a statefile. Workspaces can convert monolithic infrastructure into modular infrastructure. 
It's really helpful to manage our infrastructure configurations in different environments


**Veera** :  Thanks vijay for sharing your knowledge

**Veera** :  I would like to learn more and indepth handon experience . Where can I get it ?

**Vijay**  :  Follow  [Cloudnloud community](https://www.linkedin.com/company/cloudnloud/) and start sharing your knowledge in LinkedIn and make more visibility on your profile to become monoploy leader

**Veera** : Thanks Vijay.


** Keep Learning Keep Growing !!!**


### Community and Social Footprints : ###
- [Veerasolaiyappan](https://www.linkedin.com/in/veera26/)
- [GitHub](https://github.com/cloudnloud)
- [Twitter](https://twitter.com/cloudnloud)
- [YouTube Cloud DevOps Free Trainings](https://www.youtube.com/c/CloudnLoud)
- [Linkedin Page](https://www.linkedin.com/company/cloudnloud/)
- [Linkedin Group](https://www.linkedin.com/groups/9124202/)
- [Discord Channel](https://discord.com/invite/vbjRQGVhuF)
- [Dev](https://dev.to/cloudnloud)





