Count
Understand how to apply the count attribute in Terraform to automate the creation of multiple similar resources. This lesson teaches how to reduce code redundancy, manage resources using indexing, and handle optional resource creation efficiently within your infrastructure projects.
We'll cover the following...
In chapter Resources, we covered the basics of resources. In this chapter, we are going to cover some more advanced techniques that will help you on your Terraform journey.
Count
Let’s say that you wanted to create lots of resources and you wanted them all to be pretty much the same. This would be a pretty laborious task if you used the techniques we have learned so far since it would come down to copy and pasting a resource again and again. If you later wanted to make a change to the resource, you would have to change every copy.
Project example #1
Let’s work through an example:
In the example above, we create four ...