I’m new to Terraform and currently working on creating a schedule snapshot in GCP using Terraform. I have multiple VMs, and each VM contains at least 2 disks. I am trying to create a dynamic code so that it automatically adjusts to the number of disks. My goal is to create a separate snapshot for each VM, but I’m struggling to understand the “for_each” concept in Terraform. Could someone please explain how the “for_each” concept works in Terraform and provide an example of how I can use it to create separate schedule snapshots for each VM with multiple disks in GCP?
Any guidance or examples would be greatly appreciated. Thank you!