NOTE : DATA TYPES ARE STRING - NUMBER - LIST- MAP
BY DEFAULT IT WILL TAKE STRING
VIM TIM.TF
provider "aws" {
region = "us-east-1"
access_key = "AKVUGQ"
secret_key = "KfU0tVkt1aurid"
}
resource "aws_elb" "bar" { # load balancer search code in website
name = var.elbname
availability_zones = var.azname
listener {
instance_port = 8000
instance_protocol = "http"
lb_port = 80
lb_protocol = "http"
}
health_check {
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 3
target = "HTTP:8000/"
interval = 30
}
cross_zone_load_balancing = true
idle_timeout = 400
connection_draining = true
connection_draining_timeout = var.timeout
tags = {
Name = "cloud"
}
}
resource "aws_instance" "new1" {
ami = var.image
instance_type = var.mapvar["us-east-1a"]
tags = {
Name = var.instancetag[0]
}
}
resource "aws_instance" "new2" {
ami = var.image
instance_type = var.mapvar["us-east-1b"]
tags = {
Name = var.instancetag[1]
}
}
resource "aws_instance" "new3" {
ami = var.image
instance_type = var.mapvar["us-east-1c"]
tags = {
Name = var.instancetag[2]
}
VIM VAR.TF
}
variable "elbname" {
type = string
}
variable "azname" {
type = list
default = ["us-east-1a","us-east-1b","us-east-1c"]
}
variable "timeout" {
type = number
}
variable "instancetype" {
type = list
default = ["t2.micro","t2.medium","t2.small"]
}
variable "image"{
default = "ami-02e136e904f3da870"
}
variable "instancetag" {
type = list
default = ["new1","new2","new3"]
}
variable "mapvar" {
type = map
default = {
us-east-1a = "t2.large"
us-east-1b = "t2.medium"
us-east-1c = "t2.nano"
}
}
No comments:
Post a Comment