Terraform variable Map Type Explained!!!
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:
- 7 Most Common Mistakes in Python Programming: Student Cheat Sheet - July 14, 2020
- Understanding Kubernetes’s Taints and Tolerations in easy way - July 5, 2020
- Understanding Node Selector and Node Affinity in Kubernetes - July 5, 2020