Terraform Notes – 14 July – 2023

DevOps

YOUR COSMETIC CARE STARTS HERE

Find the Best Cosmetic Hospitals

Trusted • Curated • Easy

Looking for the right place for a cosmetic procedure? Explore top cosmetic hospitals in one place and choose with confidence.

“Small steps lead to big changes — today is a perfect day to begin.”

Explore Cosmetic Hospitals Compare hospitals, services & options quickly.

✓ Shortlist providers • ✓ Review options • ✓ Take the next step with confidence

What is Terraform?
------------------
	IAAC
	Coding for Infra.	
	-----------------
	From Hashicorp
	Written in Go.
	Release
		terraform - cli - free	======== FOCUS
		terraform enterprise - web - hosted - Paid
		terraform cloud - web - public - Paid
	version
		1.5.3
	
What is infra? == Providers
-------------------------
https://registry.terraform.io/browse/providers - 3351

Why Terraform???
======================================================
Code for Everything...
-------------------------
AWS ------> Cloud Formation
Azure -----> ARM
=====================================
ONE coding standard for ALL 
ONE CODE for ALL

ONE Code FOR ALL Providers
======================================================
How it works? Arch??
============================

Step 1 - Download Terrafrom
- https://developer.hashicorp.com/terraform/downloads
- download 
- extract
- copy to c:/tools/terraform
- set c:/tools/terraform in env path
----------------------
How to set env of tool path in powershell
How to set env of tool path in cmd
How to set env of tool path in linux
----------------------

Step 2 - Download Providers BUT using CODING
- aws
- github

#1 - How to store terraform code?
Ans - .tf

# filename
Ans - anything. main.tf

# dir/
	1.tf
	2.tf
	3.tf
------------------------
Is it one project or multiple??? 
- ONE PROJECT - ONE CODE - it merge all into oNE when u run terraform

TO DOWNLOAD PROVIDER
- Add a code to .tf
- $ terraform init



Step 3 - Write a Code
Step 4 - Run Terraform apply|destroy
Step 5 - Check the statefile







Code language: JavaScript (javascript)

providers.tf

terraform {
  required_providers {
    github = {
      source = "integrations/github"
      version = "5.30.1"
    }
	aws = {
      source = "hashicorp/aws"
      version = "5.8.0"
    }
	azurerm = {
      source = "hashicorp/azurerm"
      version = "3.65.0"
    }
  }
}

provider "github" {
  # Configuration options
}

provider "aws" {
  # Configuration options
}

provider "azurerm" {
  # Configuration options
}Code language: PHP (php)

aws.tf

resource "aws_instance" "web" {
  ami           = "ami-053b0d53c279acc90"
  instance_type = "t3.micro"

  tags = {
    Name = "HelloWorld"
  }
}

resource "aws_s3_bucket" "example" {
  bucket = "my-tf-test-bucketxxxxxxxxxxxxxx"

  tags = {
    Name        = "My bucket"
    Environment = "Dev"
  }
}

output "publicip" {
  value       = aws_instance.web.public_ip
  description = "publicip"
}Code language: JavaScript (javascript)

Commands

terraform init
terraform providers
terraform plan
terraform apply
terraform show
terraform output
terraform destory

Leave a Reply

Your email address will not be published. Required fields are marked *

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