O'Reilly logo

Getting Started with Terraform - Second Edition by Kirill Shirinkin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using map variables

If you've used maps, dictionaries, or hashes in some programming language such as Ruby, then you know what Map in Terraform is. Map is a lookup table, where you specify multiple keys with different values. You can then pick the value depending on the key. It's easier to understand it with the example.

At the moment our MightyTrousers application always uses the t2.micro instance type. These are cheap instances that are good for quick tests and development, but they are not that great for production. What we want, actually, is a way to use different instance types depending on the environment stack is deployed to. Let's assume that we have only three environments: dev, prod, and test.

First, let's move variables out of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required