Infrastructure as Code with OpenTofu (Terraform-Compatible) and Ansible
Exit

Lesson 6 of 10 · Building

Loops and conditions: count, for_each, dynamic and expressions

45 min Debian 12

Objective

Describe ten servers without writing ten blocks, create a resource only in production, transform lists and objects, and generate nested blocks (firewall rules, for example) from a variable. You will also learn to choose between count and for_each, a choice that has consequences for the state.

This lesson is part of the full course

Unlock Infrastructure as Code with OpenTofu (Terraform-Compatible) and Ansible to read every lesson, do the exercises, access the simulations and earn your certificate.

Already enrolled? Log in.