Terraform Notes – Day 1 & Day 2 – July 2023

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now
What is terraform?
-------------------
	Coding for infra
	IAAC

	From Hashicorp
	Go
	Release
		cli - free & os
		web 
			Cloud
			Enterprise
	version
	- 1.5X

Whats in infra?
--------------------
https://registry.terraform.io/browse/providers - 3316

Why terraform?
-------------------
	Coding for all

	create - update - destory
	==========================
		ONE CMD

ONE CODING STANDARD FOR ALL PROVIDERS
--------------------
	hcl
Easy 2
	read
	write
	test
	debug
	share


How it works???		== terraform Architecture
-------------------

create -> Update -> Destroy
-----------------
	apply	    destroy

=====================================================
How to store terraform code? - .tf

dir
	file1.tf + file2.tf + file3.tf
	=============================
		one.tf
	
==============================================================================================

How to write a code in terraform?
=====================================

tf
	Resource1
		arguments1
		arguments2
		arguments3

	Resource2
		arguments1
		arguments2
		arguments3

	Resource3
		arguments1
		arguments2
		arguments3


resource "aws_instance" "web" {
  ami           = ami-06b09bfacae1453cb
  instance_type = "t3.micro"

  tags = {
    Name = "HelloWorld"
  }
}

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}





providers.tf
----------------
terraform {
  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = "3.63.0"
    }
	aws = {
      source = "hashicorp/aws"
      version = "5.6.2"
    }
  }
}

provider "azurerm" {
  features {}
  client_id       = "02cab381-968e6-ae25-dea240f2ee4b"
  client_secret   = "T5r8Q~3FWhZsvkMGNwTgkcUb20y8OrnScQv"
  tenant_id       = "f34c8fc4-16b8-4de3-8110-45904e3b1d1a"
  subscription_id = "ab1f1735-1"
}


provider "aws" {
  region     = "us-east-1"
  access_key = ""
  secret_key = "/QR3dPT"
}


aws.tf
-----------
resource "aws_instance" "web" {
  ami           = "ami-06b09bfacae1453cb"
  instance_type = "t3.micro"

  tags = {
    Name = "HelloWorld"
  }
}


output "public_ip_address" {
  value = aws_instance.web.public_ip
}

azure.tf
-----------
resource "azurerm_resource_group" "example" {
  name     = "example-resourcessss"
  location = "West Europe"
}

terraform version
terraform help
terraform init
terraform plan
terraform validate
terraform apply
terraform show
terraform output
terraform providers

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x