Skip to content

Commit 054251e

Browse files
committed
docs(cfn-lang-ext): correct validation errors table to match code
The previous table paraphrased messages and listed an error that doesn't exist: - Layout error: actual message is "Fn::ForEach::<key> layout is incorrect" and covers more cases than just element count (non-list value, non-string identifier, etc.). - Nesting depth: actual message is the multi-line "Fn::ForEach nesting depth of <N> exceeds the maximum allowed depth of 5. CloudFormation supports up to 5 nested Fn::ForEach loops." - Missing parameter referenced by Fn::ForEach: there is no such error. In partial mode (typical sam build/package), the unresolved Ref is preserved and CFN rejects it at deploy time. - Empty collection: no message; silently skipped (kept as-is).
1 parent 324eea4 commit 054251e

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

docs/cfn-language-extensions.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,12 @@ Functions that require deployed resources (`Fn::GetAtt`, `Fn::ImportValue`, `Fn:
267267

268268
The following template issues are caught locally before the SAM transform runs:
269269

270-
| Error | Cause |
271-
|-------|-------|
272-
| `Fn::ForEach must have exactly 3 elements` | The `Fn::ForEach` value is not a 3-element list (`[loop_variable, collection, output_template]`). |
273-
| `Maximum nesting depth of 5 exceeded` | More than 5 levels of `Fn::ForEach` are nested. |
274-
| `Parameter '<name>' referenced by Fn::ForEach not found` | The `!Ref` in the collection points at a parameter that is not declared in the template. |
275-
| Empty collection | If the collection resolves to an empty list (e.g., a `CommaDelimitedList` parameter with `Default: ""`), no resources are emitted — the loop is silently skipped. |
270+
| Cause | Error message |
271+
|-------|---------------|
272+
| The `Fn::ForEach` value is malformed — not a list, doesn't have exactly 3 elements, or has a non-string loop identifier. | `Fn::ForEach::<key> layout is incorrect` (raised as `InvalidTemplateException`; see `samcli/lib/cfn_language_extensions/processors/foreach.py`). |
273+
| More than 5 levels of `Fn::ForEach` are nested. | `Fn::ForEach nesting depth of <N> exceeds the maximum allowed depth of 5. CloudFormation supports up to 5 nested Fn::ForEach loops.` |
274+
| The collection resolves to an empty list (e.g., a `CommaDelimitedList` parameter with `Default: ""`). | No error — the loop is silently skipped and no resources are emitted. |
275+
| The `!Ref` in the collection points at a parameter that is not declared in the template. | No error in the typical `sam build` / `sam package` flow. SAM CLI runs intrinsic resolution in PARTIAL mode and preserves the unresolved `{"Ref": "<name>"}`. CloudFormation will reject the unresolved ref at deploy time. |
276276

277277
## Limitations
278278

0 commit comments

Comments
 (0)