Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

Terraform Tutorials: Variables – Data Type – Map

In this example, the instance_tags variable is defined with a type of map(string), and it is given a default value of { Name = "my-instance" }. The AWS provider is then configured to use the us-west-2 region.

The aws_instance resource is used to launch Amazon EC2 instances. The tags argument is used to assign tags to the instance, and it is set to the value of the instance_tags variable.

You can change the value of instance_tags by modifying the default value in the variable definition, or you can specify a different value when you run Terraform by using the -var flag. For example, if you want to launch an instance with tags { Name = "my-instance", Environment = "prod" }, you can run the following command:

$ terraform apply -var ‘instance_tags={ Name = “my-instance”, Environment = “prod” }’


Maps are a collection of string keys and string values. These can be useful for selecting values based on predefined parameters such as the server configuration by the monthly price.

We’ve replaced our sensitive strings with variables, but we still are hard-coding AMIs. Unfortunately, AMIs are specific to the region that is in use. One option is to just ask the user to input the proper AMI for the region, but Terraform can do better than that with maps.

dynamic lookup – The square-bracket index notation used here is an example of how the map type expression is accessed as a variable, with [var.region] referencing the var.amis declaration for dynamic lookup.

static value lookup – the map type expression can also use a static value lookup directly with var.amis[“us-east-1”].

Maps are a way to create variables that are lookup tables. An example will show this best. Let’s extract our AMIs into a map and add support for the us-west-2 region as well:

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at <a href="https://www.cotocus.com/">Cotocus</a>. I share tech blog at <a href="https://www.devopsschool.com/">DevOps School</a>, travel stories at <a href="https://www.holidaylandmark.com/">Holiday Landmark</a>, stock market tips at <a href="https://www.stocksmantra.in/">Stocks Mantra</a>, health and fitness guidance at <a href="https://www.mymedicplus.com/">My Medic Plus</a>, product reviews at <a href="https://www.truereviewnow.com/">TrueReviewNow</a> , and SEO strategies at <a href="https://www.wizbrand.com/">Wizbrand.</a> Do you want to learn <a href="https://www.quantumuting.com/">Quantum Computing</a>? <strong>Please find my social handles as below;</strong> <a href="https://www.rajeshkumar.xyz/">Rajesh Kumar Personal Website</a> <a href="https://www.youtube.com/TheDevOpsSchool">Rajesh Kumar at YOUTUBE</a> <a href="https://www.instagram.com/rajeshkumarin">Rajesh Kumar at INSTAGRAM</a> <a href="https://x.com/RajeshKumarIn">Rajesh Kumar at X</a> <a href="https://www.facebook.com/RajeshKumarLog">Rajesh Kumar at FACEBOOK</a> <a href="https://www.linkedin.com/in/rajeshkumarin/">Rajesh Kumar at LINKEDIN</a> <a href="https://www.wizbrand.com/rajeshkumar">Rajesh Kumar at WIZBRAND</a> <a href="https://www.rajeshkumar.xyz/dailylogs">Rajesh Kumar DailyLogs</a>

Related Posts

Terraform Tutorials: Local Values using Local Block

What is local value in terraform? In Terraform, a locals block is used to define local variables within a module, allowing you to create reusable expressions and…

Read More

Terraform Tutorials: Module Complete Guide

A Terraform module is a collection of configuration files that encapsulate resources used together to achieve a specific outcome. Modules promote reusability, organization, and maintainability in infrastructure…

Read More

What is Terrafile?

Terrafile is a tool used to manage Terraform modules as dependencies. It simplifies the process of downloading and managing Terraform modules by automating the fetching of modules…

Read More

What is Terraform and use cases of Terraform?

What is Terraform? Terraform is a infrastructure as code (IaC) tool and open-source from HashiCorp. It empowers users to define and manage cloud infrastructure and on-premises resources…

Read More

What is HashiCorp Terraform and use cases of HashiCorp Terraform?

What is HashiCorp Terraform? HashiCorp Terraform is a leading infrastructure as code (IaC) tool, empowering you to define, provision, and manage your cloud and on-premises infrastructure in…

Read More

Terraform Tutorials: What is terraform.tfvars with example

What is terraform.tfvars? Terraform .tfvars files are used to store variable definitions. This allows you to externalize your variable definitions and makes it easier to manage them,…

Read More