A LOOK INTO THE TERRAFORM VARIABLES

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

1.Types of Terraform variable – Number

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.0"
    }
  }
}

provider "aws" {
  region = "us-west-2"
  access_key = ""
  secret_key = ""
}


variable "numofusers" {
  type = number
  description = "This is for demo of number variable"
  default = 3
}
resource "aws_instance" "first-ec2" {
  ami            = "ami-03d5c68bab01f3496"
  instance_type  = "t2.micro"
}
provider "github" {
  token        = "ghp_mCsNU213nRzomV9xIIQCg4jkS2meo1UAP3H"

}

resource "github_repository" example" {
  name        = "Akshatha Ashwathnarayan"
  description = "My code"

}
 

  

2.Types of Terraform variable – String.

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.0"
    }
  }
}

provider "aws" {
  region = "us-west-2"
  access_key = ""
  secret_key = ""
}


variable "username" {
  type = string
  description = "This is for demo for string variable"
  default = "user"
}
resource "aws_instance" "first-ec2" {
  ami            = "ami-03d5c68bab01f3496"
  instance_type  = "t2.micro"
}
provider "github" {
  token        = "ghp_mCsNU213nRzomV9xIIQCg4jkS2meo1UAP3H"

}

resource "github_repository" example" {
  name        = "Akshatha Ashwathnarayan"
  description = "My code"


}
3. Types of Terraform variable – List

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.0"
    }
  }
}

provider "aws" {
  region = "us-west-2"
  access_key = ""
  secret_key = ""
}


variable "users" {
  type = list
  description = "This is for demo for list variable"
  default = "list"
}
resource "aws_instance" "first-ec2" {
  ami            = "ami-03d5c68bab01f3496"
  instance_type  = "t2.micro"
tags = {
  name        = "Akshatha Ashwathnarayan"

}
4. Types of Terraform variable – Map

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.0"
    }
  }
}

provider "aws" {
  region = "us-west-2"
  access_key = ""
  secret_key = ""
}


variable "amis" {
  type = map
  description = "This is for demo for amis variable"
  default = "user"
}
resource "aws_instance" "first-ec2" {
  ami            = "ami-03d5c68bab01f3496"
  instance_type  = "t2.micro"
}
provider "github" {
  token        = "ghp_mCsNU213nRzomV9xIIQCg4jkS2meo1UAP3H"

}

resource "github_repository" example" {
  name        = "Akshatha Ashwathnarayan"
  description = "My code"


}
5. Types of Terraform variable – Boolean

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.0"
    }
  }
}

provider "aws" {
  region = "us-west-2"
  access_key = ""
  secret_key = ""
}


variable "set-password" {
  type = string
  description = "This is for demo for boolean variable"
  default = "false"
}

variable "create_vm" {
  description = "If set to true, it will create vm"
   type   = bool
}

variable "create_vmss" {
  description = "If set to true, it will create vmss"
  type = bool
}
resource "aws_instance" "first-ec2" {
  ami            = "ami-03d5c68bab01f3496"
  instance_type  = "t2.micro"
}
provider "github" {
  token        = "ghp_mCsNU213nRzomV9xIIQCg4jkS2meo1UAP3H"

}

resource "github_repository" example" {
  name        = "Akshatha Ashwathnarayan"
  description = "My code"


}