More Complex Variables
Explore how to declare and use complex variables in Terraform, focusing on maps to dynamically choose AWS instance types based on environment. Learn how to adjust variables like environment_type and instance_map to tailor deployments across multiple environments and departments.
We'll cover the following...
We'll cover the following...
Project example
Let’s look at a more complex example using a map and selecting a value from it with variables:
instance_map = {
dev = "t3.small"
test = "t3.medium"
prod = "t3.large"
}
environment_type = "dev"Variables complex project example
-
In our variables file, we are setting
instance_mapto a map. -
A map is a collection of values indexed by a key name. We have set three keys in our map
devtest