========================================
Any Qs - Any time
========================================
9:AM - 5 PM
========================================
Lunch Time - 12:30 PM - 1 Hour
Tea tme
10:30 AM - 15 mns
3 PM - min
Workstation - Windows
Cloud - Azure |
=========================================
Access - Azure
============================================================
Slides - https://devopsschool.com/slides/terraform/
Tutorials:
-------------------------------------------------------------
What is Terraform?
-------------------------------------------------------
Coding for Infra = IAAC
From Hasicorp
Written in GOlang
Release
Community - CLI
Enterprise - WEB
Cloud - WEB = https://app.terraform.io/
Version
1.6.0
Whats there in Infra?
----------------------------------
https://registry.terraform.io/browse/providers
Why We need terraform?
------------------------------------------------------
So many Platform
So many Lang spec
So many Coding Standard
one is not working for other
Consitent change mgmt
--------------------------------
How it works?
======================================================
Step 1 - Installl Terraform
Step 2 - Install Providers
Step 3 - Write A code
Step 4 - Run a code
Step 5 - Validate the state file
Installl Terraform
Step 2 – Install Terraform Providers (Plugins)
You can install providers using CODE.
How to store terraform code?
---------------------
anyfilename.tf
Directory === file1.tf + file2.tf + file3.tf
================================
ONE PROJECT
ONE CODE
All TF code merged into ONE
During - Apply - Destory
Azure
AWS
Github
--------------------------------------
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.75.0"
}
}
}
provider "azurerm" {
# Configuration options
}
--------------------------------------
How to download providers? | First time | Upgrade
$ terraform init
-------------------------------------------------
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.75.0"
}
aws = {
source = "hashicorp/aws"
version = "5.20.0"
}
}
}
provider "azurerm" {
# Configuration options
}
provider "aws" {
# Configuration options
}
Step 3 – How to write a Code in Terraform?
====================================================
Rule#1 - You MUST know Provider(Azure)
Rule#2 - You MUST know the resources provider by Terrafrom
IMPORTANT - https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource#1
argument#1
argument#2
argument#3
resource#2
argument#1
argument#2
argument#3
resource#3
argument#1
argument#2
argument#3
resource "azurerm_resource_group" "example" {
name = "example"
location = "West Europe"
}
resource "azurerm_resource_group" "example-rg" {
name = "example"
location = "West Europe"
}
====================================================================================
Command workflow in Terraform
-----------------------------------
validate Check whether the configuration is valid
plan Show changes required by the current configuration
apply Create or update infrastructure
show Show the current state or a saved plan
destroy Destroy previously-created infrastructure
How to Authenticate Azure using service princial and token/