Filtering maps
In the previous recipes of this chapter, we learned different use cases for looping over collections using the for
and for_each
expressions.
In some scenarios, we may need to create resources from an existing list, but the requirement is to filter only some elements from this list.
In this recipe, we will learn how to filter a list to provision resources.
Let’s get started!
Getting ready
To complete this recipe, you’ll need to know about looping with the for_each
expression, which was covered in the Looping over object collections recipe of this chapter.
The starting element of this recipe is the following list of objects. This object list contains some properties of the resources needed for our App Service use cases:
web_apps = [
webapp1 = {
"name" = "webapptestbook1"
"os" = "Linux"
},
webapp2 = {
"name" = "webapptestbook2"
"os" ...