# Error: Invalid dynamic block iterator: The iterator for a dynamic block must be a single word, not a complex expression

- **ID:** `terraform/dynamic-block-iterator-invalid`
- **Domain:** terraform
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

The dynamic block's iterator argument is set to a complex expression (like a function call or attribute reference) instead of a simple variable name.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Terraform 1.4.0 | active | — | — |
| Terraform 1.5.0 | active | — | — |
| Terraform 1.6.0 | active | — | — |

## Workarounds

1. **Use a simple, single-word identifier for the iterator that is not already in use in the current scope. For example, if iterating over a list of tags, use 'tag' as the iterator.** (95% success)
   ```
   Use a simple, single-word identifier for the iterator that is not already in use in the current scope. For example, if iterating over a list of tags, use 'tag' as the iterator.
   ```
2. **If you have nested dynamic blocks, use distinct iterator names for each level, such as 'outer' and 'inner'.** (90% success)
   ```
   If you have nested dynamic blocks, use distinct iterator names for each level, such as 'outer' and 'inner'.
   ```

## Dead Ends

- **** — The iterator must be a new variable name, not an existing expression. Terraform uses it to create a temporary variable within the block. (90% fail)
- **** — The default iterator 'each' works only if not already used by another dynamic block in the same resource. If 'each' is used elsewhere, it causes conflicts. (60% fail)
- **** — The iterator must be an unquoted identifier, not a string. Quoting makes it a string literal, which is not a valid variable name. (95% fail)
