TF Classnotes

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

What is Terraform?

->Terraform is OpenSource Software Tool

->Terraform is platform Agnostic(not specific to single cloud) Tool

Different cloud platforms:

1. AWS

2. Azure

3. GCP

4. Alibaba

5. Oracle

6. IBM cloud

10 of hunderes of clouds

->Terraform id IaC(Infrastructure as a Code)

->Terraform is developed by HCL(HassiCorp Configuration Language)

->Terraform is created by "go" language

->Terraform provide DSL(Domain Specific Language) for provisioners

->it look like JSON or yaml

Ansible:

->is also opensource

->it is platform independent

->is configuration management tool

is used to install,update,delete the softwares or application or web


servers

ie:after provisioning the infrastructure it is usefull

if you want to provision(crete) infrasture Terraform is useful.

mainly in Terraform we can use only 5 keywords

init Prepare your working directory for other commands


validate Check whether the configuration is valid
plan Show changes required by the current configuration
apply Create or update infrastructure
destroy Destroy previously-created infrastructure
1. init ->it is used to initialize plugin(download and useful within the folder)

2. validate->it can validate the user code(.tf file)(check the syntax of DSL)

3. plan: it can gather expected things(virtual) --syntax-check

4. apply it will provision expected thins can be converted to actural(physical)

5. destroy: it can remove what ever provisioned(seconds 30, 60,90 etc)

init -> validate -> plan -> apply -> destroy

DSL:

providers: is the communication with any cloud provider

eg:

providerblock "providername"{

provider "aws"{

argument1 = "value1"

....................
argumentn = "valuen"

provider "azure"{

provider "ibm"{

access key:AKIAYLYO7HCX6HI2E3H5

secret key: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

resource

->Terraform is a opensuorce, platform Agnostic Tool


->Terraform is a IaC tool
->Terraform is a Infrastructure provisioning tool
->Infrastructure can be created in almost all the virtual enviroments.

->Terraform is an infrastructure as a code tool that allows you to build,change,and


version infrastructure safely and efficiently

-> Terraform provides infrastructure automation

-> Terraform templates are written in custom DSL


->The DSL mostly look like JSON

->Terraform templates ends with .tf extension

->Terraform developed by HCL,written in go language

Installation:

->windows:
choco install terraform

->linux

Components of Terraform:

-> Providers: providers are used to create infrastructure in particular virutal


enviroment

interaction componet
eg: aws,azure,gcp,ibm
-> Resources:is the part of the infrastructure create on the provider.
Every provider provide resources.

are infrastrucr objects like


eg:vpc,ec2,elasticip etc
-> variables: to give options to the user to enter different values to resources.
deployment is more dynamic
-> statefile:it maintain the current state of the infrastructure.
-> provisioners:provide the ability to run additional steps(like ansible)
-> backends
-> modules
-> datasources
-> serviceprinicples

eg1:
install terraform
install vscode

provider syntax:
provider 'provider type'
{
argument1 'value1'

}
inputs in terraform as called as arguments
outputs are called as attributes.
provider "aws" {
region = us-east-1
access_key = AKIAYLYO7HCX2MIJU4PR

secret_key = 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

akey:AKIAYLYO7HCXTJICXWZJ
skey:AQ5oz9/mba0Qxw+4t6lA4qAs2LObr2tnVH4w+6y7

resource "aws_vpc" "my-vpc" {

cidr_block = "10.0.0.0/16"
instance_tenancy = "default"
tags = {
name = "my-vpc"
}
}

You might also like