A CloudFormation template has up to **nine top-level sections**. Only `Resources` is required; all others are optional. The nine sections, in conventional declaration order:
```
AWSTemplateFormatVersion → Description → Metadata → Parameters →
Rules → Mappings → Conditions → Transform → Resources → Outputs
```
The order is conventional, not enforced — but later sections often reference earlier ones, so the order keeps reading top-down sensible.
## Section purposes
| Section | Purpose | Required |
|---------|---------|----------|
| `AWSTemplateFormatVersion` | Pin template language version (currently `2010-09-09`) | No |
| `Description` | Free-text human description shown in console | No |
| `Metadata` | Arbitrary template-level info; doubles as JSON's comment workaround | No |
| `Parameters` | Runtime input values; referenced from Resources/Outputs via `!Ref` | No |
| `Rules` | Validate parameters or parameter combinations during create/update | No |
| `Mappings` | Static lookup tables (region → AMI, env → instance type); accessed via `Fn::FindInMap` | No |
| `Conditions` | Boolean expressions controlling whether resources/properties materialize | No |
| `Transform` | Apply macros — most commonly `AWS::Serverless` (SAM) or `AWS::Include` (snippets) | No |
| `Resources` | Declare AWS resources to provision (logical ID + Type + Properties) | **Yes** |
| `Outputs` | Stack-level return values (resource IDs, URLs); usable cross-stack via Exports | No |
## Hard rule: no duplicate sections
Don't declare the same major section twice (e.g., two `Resources:` blocks). CFN may accept the template, but behavior is **undefined** — it can mis-provision resources or return inexplicable errors. This is a YAML/JSON-level mistake CFN does not validate against.
## Skeleton
YAML, all sections present:
```yaml
---
AWSTemplateFormatVersion: 2010-09-09
Description: String
Metadata:
template metadata
Parameters:
set of parameters
Rules:
set of rules
Mappings:
set of mappings
Conditions:
set of conditions
Transform:
set of transforms
Resources:
set of resources
Outputs:
set of outputs
```
## Mental model
Three categories of sections by what they do:
1. **Inputs**: `Parameters`, `Mappings` (and `Rules` validating them)
2. **Logic gates**: `Conditions`, `Transform`
3. **Outputs**: `Resources` (the actual provisioning), `Outputs` (return values)
Plus three **metadata-only** sections: `AWSTemplateFormatVersion`, `Description`, `Metadata`.
This 3+3+3 grouping is more useful than memorizing the linear list — you reach for sections by *role*, not by alphabetical position.
## Related
- [[CFN Template Format JSON vs YAML]]
- [[CFN Regex Support and Gotchas]]