\n## What Is the for_each Meta-Argument?\n\nThe for_each meta-argument lets Terraform create multiple instances from one block by iterating over a map or a set of strings. Like count, it reduces repetition. Unlike count, it identifies each instance by a key rather than a numeric position.\n\nThat difference is what makes for_each so valuable for real infrastructure.\n\nHere is a simple example:\n\n```hcl\nresource "aws_s3_bucket" "logs" {\n for_each = toset(["dev", "staging", "prod\
Learn Terraform expressions: types, references, conditionals, for expressions, key function categories, try and can, and testing in terraform console.
Work with strings in Terraform: interpolation, format, case and whitespace helpers, replace and regex functions, templatefile and conditionals.
Learn Terraform collection functions such as concat, flatten, distinct and slice, plus map and set helpers and for expressions for dynamic code.