# HashiCorp Configuraton Language (HCL) Basics

Hello Folks, we are moving ahead with our Infrastructure as Code series with Terraform. We are going to discuss the basics of HCL the language used in the terraform tool. The new name for this language is Terraform Language in the newer versions. Let's get started.

This is for version 0.11 or earlier.
An HCL file has blocks and arguments
A block is defined within curly braces and contains arguments in key value pair format representing config data.

What information is kept in the block
The platform and the resources in the platform
First  element is block called resource block id by word resource
Then we have the resource type and then inside the resource block we have arguments in the form of key value pair

Simple Terraform workflow is as follows
1. Write the Terraform configuration file.
2. Run the *init* command
3. Review the execution plan using *plan* command
4. Once ready, apply changes using *apply* command

When we run the *terraform init* command, Terraform will check the configuration file and initialize the working directory containing the .tf file.
It will understand the resource type and download the appropriate provider to work on the resources declared in the .tf file
Now the resource can be created..
If we want to see the steps involved in the creation of the resource, run the *terraform plan* command.
The + symbol signifies that resource will be created.
Once we have verified all the steps, run the *terraform apply* command.
It will show the execution plan once again and ask the user’s confirmation to proceed with the steps.
Then run the *terraform show* command to view the details of the created resource.
To know the resource types supported by a provider and the arguments needed, refer to the terraform documentation.

## Update and Destroy Infrastructure
Once the necessary changes are done
When the *terraform plan* is run, the output shows that resource will be replaced
-/+ shows that the resource will be deleted and recreated
Even though the change is small, Terraform will delete and recreate the file
This infrastructure is called **immutable** infrastructure.
To continue with the change, run the command *terraform apply* and type yes to confirm
To destroy the infrastructure, run the command *terraform destroy*
An execution plan is shown and when we give the confirmation yes, terraform proceeds to perform the action.

