Just as Terraform offers several different ways to do loops, there are also several different ways to do conditionals, each intended to be used in a slightly different scenario:
count parameter. Used for conditional resources
for_each and for expressions. Used for conditional resources and inline blocks within a resource
if string directive. Used for conditionals within a string
Let’s go through these, one at a time.