Terraform & Devops
  • Home
  • TERRAFORM CERTIFCATION
  • AWS-CLOUD
  • GCP-CLOUD
  • ANSIBLE
  • KUBERNETES
  • Aboutus
  • Contact Us
No Result
View All Result
  • Home
  • TERRAFORM CERTIFCATION
  • AWS-CLOUD
  • GCP-CLOUD
  • ANSIBLE
  • KUBERNETES
  • Aboutus
  • Contact Us
No Result
View All Result
Terraform & Devops
No Result
View All Result
Home TERRAFORM CERTIFCATION

Types Of Variables In Terraform

by abubakarsiddiq858
January 4, 2021
in TERRAFORM CERTIFCATION
159 9
0
Types Of Variables In Terraform
192
SHARES
2.4k
VIEWS
Share on FacebookShare on Twitter

Variable types


In this article we will demonstrate various ways of passing Terraform variables.

Declaring String Variables:

Variable “image_id” {
type = string
description = “The id of the machine image (AMI) to use for the server.”
}

Map variable:


Map variables refers refers to key value pair
Usage:
Variable “mappi” {
Type = “map”
Default = {
ap-south-1=”t2.small”
us-east-1=”t2.large”
}
“In the above example keys are regions and the values associated with the keys are instance types.based on the region the instance type will be launched.

 


List variable

List variables take a list of values. It refers index that starts from zero.

variable “listii” {
type = list
default = [“t2.small”, “t2.large”]
}
Terraform automatically loads a number of variable definitions files if they are present:
* Files named exactly terraform.tfvars or terraform.tfvars.json.
* Any files with names ending in .auto.tfvars or .auto.tfvars.json.

Terraform count


The count parameter on resources can simplify configurations and let you scale resources by simply incrementing a number.
For example
Resource “aws_instance” “myserver” {
ami = “ami-05d66”
instance_type =”t2.medium”
count = 3
tags ={
name = “devservers”
}
In the above example we assigned count value is 3 so therefore it creates three instances with same tag devservers for all three instances.

 

To create 3 resources with 3 names that performs interation use count.index on that

$ is refered as interpolation

resource “aws_iam_user” “hello” {
name = “hello.${count.index}”
count = 3
path = “/system/”
}

Tags: Business AnalysisInvestment LossMarket StoriesUnited StatedVenture CapitalWall Street

Recent News

Implementing VPC Architecture using Terraform

Implementing VPC Architecture using Terraform

August 28, 2021
Build a CICD Pipeline with Git Jenkins Terraform

Build a CICD Pipeline with Git Jenkins Terraform

May 24, 2021

Categories

  • Uncategorized
  • AWS-CLOUD
  • TERRAFORM CERTIFCATION

Site Navigation

  • Home
  • Advertisement
  • Contact Us
  • Privacy & Policy
  • Other Links
Terraform & Devops

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Check our landing page for details.

No Result
View All Result
  • Home
  • TERRAFORM CERTIFCATION
  • AWS-CLOUD
  • GCP-CLOUD
  • ANSIBLE
  • KUBERNETES
  • Aboutus
  • Contact Us

© 2021 TheTerraform.in - All Rights Reserved.
Designed By TenXinfotech.

Welcome Back!

Login to your account below

Forgotten Password?

Create New Account!

Fill the forms below to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In

Add New Playlist