Terraform – Notes – Day 3 – August

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

Terraform Backend

https://developer.hashicorp.com/terraform/language/settings/backends/configuration
https://www.devopsschool.com/blog/terraform-backend-tutorial
https://developer.hashicorp.com/terraform/language/settings/backends/s3

terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = "5.12.0"
    }
	azurerm = {
      source = "hashicorp/azurerm"
      version = "3.69.0"
    }
	github = {
      source = "integrations/github"
      version = "5.33.0"
    }
  }
  backend "s3" {
		bucket = "rajesh34444444444444444444555"
		key    = "devopsschoolapp/terraform.tfstate"
		region = "us-east-1"
        access_key = ""
        secret_key = ""
  }
}

BACKEND

Can TF integrate with CM like Ansible? What is the industry best practice in terms of TF's provisioner vs integration with other tools?
===================================================================================================================================


SDLC
------------------------------------------------------------
PLAN -> Code -> Analyze -> Build -> UT -> Package -> Archive -> Dep2QA -> AT -> CC
====================================================================================
JIRA	GIT	SonarQube  Maven    JUnit  Packer   Artifactory  Ansible  Selenium  Jacoco
CONF
========================================================================================
					jenkins


Packer
	Create a AMI Using Packer
			Config ur app in Server using Ansible

	Create a Infra using terraform which contains AMI created using Pack

	


											PASSED - Release -----> Dep2Prod
										1Failed - Repeat
Dep2QA
==============
Create a QA infra using Terraform
Config ur app in Server using Ansible

Ansible - Configure your SERVER(S)
Terraform - Can Create SERVERS+Infra


  provisioner "remote-exec" {
    inline = [
	  "git clone repo-url-which-container-plybook
	  "ansible-playbook localhost app.yaml",
    ]
  }



app.yaml --github
=====================================================================================================
WORKSPACE
https://www.devopsschool.com/blog/terraform-workspace-explained

terraform workspace
terraform workspace list
terraform workspace new dev
terraform workspace list
terraform plan
terraform apply --auto-approve
terraform workspace list
terraform workspace select default
terraform workspace list
terraform workspace delete dev
terraform workspace select dev
terraform destory --auto-approve
terraform destroy --auto-approve

Function

Template

DataSource

data "aws_ami" "ubuntu" {
  most_recent = true

  filter {
    name   = "name"
    values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-20230516"]
  }

  filter {
    name   = "virtualization-type"
    values = ["hvm"]
  }

  owners = ["099720109477"] # Canonical
}

data "aws_availability_zones" "available" {
  state = "available"
}

output "virtual_machine_id" {
  value = data.aws_availability_zones.available.names[0]
}

output "virtual_machine_id1" {
  value = data.aws_availability_zones.available.names[1]
}


output "ips_with_list_interpolation" {
  value = [ for name in data.aws_availability_zones.available.names : name ]
}

resource "aws_instance" "first-ec2" {
  ami           = data.aws_ami.ubuntu.id # us-west-2
  instance_type = "t2.micro"
  tags = {
    Name = "RajeshKumar"
  }
  }

How to find a training

Notes?
https://www.bestdevops.com/terraform-notes-day-2-august/
https://www.bestdevops.com/terraform-notes-day-3-august/
https://www.bestdevops.com/terraform-notes-day-1-august/

Slides
https://devopsschool.com/slides/terraform/index.html

Tutorials
https://www.devopsschool.com/blog/?s=terraform

Videos
https://www.youtube.com/@sreschool
https://www.youtube.com/@DevSecOpsSchool
https://www.devopsschool.com/blog/top-4-youtube-channel-for-free-videos-tutorials/

Commands
https://www.devopsschool.com/commands
https://www.devopsschool.com/cheatsheets/

Quiz
https://www.devopsschool.com/lms/course/view.php?id=42
Trainer – Rajesh Kumar
https://www.rajeshkumar.xyz/

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