Terraform was first introduced in July 2014
Terraform uses hashicorp Language, it is similar to JSON, but easy and human readble.
Infrastructure as code(IAC) is the managing and provisioning of infrastructure through code instead of through manual process.
There are tow types of IAC Tools
1) Vendor Specific
- AWS - Coudformation
- Azure - ARM Template
- GCP - Deployment Group
- OpenStack - Heat
2) OpenSource
- Terraform
There are tow ways to approach IAC
1) Imperative : Approach defines the specific needed to archive the desired configuration and those commands needs to be executed in correct order.
(Imperative method means "Step by Step") cloud-formation use this.
2) Declarative : Approach define the desired state of the system including what resources you need and any properties should have and an IAC tool will configure it for you. (Terraform use this)
It is important to understand the difference b/w Configuration Management Tool(CMT) and Infrastructure As Code(IAC) tool.
- Ansible, Chef and Puppet are CMT which means they are primarily designed to install and manage s/w on existing servers.
- Terraform and Cloudformation are IAC tool which are designed to provision servers and Infrastructure themselves.
You can use IAC and CMT all together for eg: you could use terraform to create a new EC2 instance on AWS, Terraform can then call Ansible to install and configure s/w and application on the EC2 Instances.
What is Providers ?
A provider is responsible for understanding API introduction and exposing resources if an API is available, You can create a provider A provider use plugin In order to make a provider available in terraform, we need to make a terraform init, thus commands download any plugins we need for our providers.
What is Terraform INIT ?
the terraform init command is used to initialize a working directory containg terraform configuration files it is safe to run that command to multiple times
this command will never delete your old configuration or state during init the root directory is consulted for backend configuration and the chosen backend is initialized using the given configuration settings.
What is Terrafrom Validate ?
The terraform validate command validate the configuration files in a directory referring only to the configuration and not accessing any remote services such as remote state, provider API etc. Validate runs checks that verify weather a configuration is syntactically valid and internally consist, regardless of any provided variables or existing state it is thus useful in general verification of reusable modules including correctness of attributes names ans value type.
What is Terraform Plan ?
the terraform plan command is used to create an execution plan terraform performs a refresh, unless explicitly disabled and then determines what actions are necessary to archive the desired state specified in the configuration files.
What is terraform Apply ?
the terraform Apply command is used to apply the changes required to reach the desired state of the configuration or the pre-determind set of actions generated by a terraform plan execution plan.
What is terraform Destroy ?
the terraform destory command is used to destory the terraform-managed infrastructure.
HCL syntax is basic and should be readble by the familer with other scripting languages It has three parts:
- Block : group expression, arguments and other blockes into labelle structure, which extend blocks can then refresh its curly bracket syntax it shared by most object-oriented languages.
- Arguments : are an abstraction that enable IT admins to assign values to descriptive names, which can represent or compute values, they can be simple, such as a string or numeric value, or more complicated such as aromatic or logical expression.
- Expression: expression either represent or compute values. they can be simple such as string or numeric value or more complicated such as arithmetic or logical expression.
No comments:
Post a Comment
testing