Example minimal CloudFormation template (s3-bucket.yaml)
Install cfn-lint
- Open Visual Studio Code and open the integrated terminal (View → Terminal or the toggle panel icon).
- Install cfn-lint using pip:

Validate a template with cfn-lint
With your S3 template file open (s3-bucket.yaml), run cfn-lint from the terminal:- A successful run produces no error output — cfn-lint returns without printing errors or warnings.
- If it finds issues, cfn-lint prints descriptive error codes and locations so you can quickly correct the template.
Common errors cfn-lint catches (examples and fixes)
Below are several typical mistakes and how cfn-lint helps identify them.- Indentation / YAML structure errors
Incorrect YAML indentation can cause the parser to miss required top-level keys such asResources. Example malformed YAML (no indentation):
Resources mapping, the linter interprets them as unexpected top-level properties. Correcting indentation to:
- Simple spelling / key name mistakes
Using an incorrect key such asResource(singular) instead ofResources(plural) triggers clear messages:
Resources and re-running cfn-lint returns no errors:
Use cfn-lint on every CloudFormation template you author. It catches YAML formatting issues, schema problems, misspelled keys, and provides actionable error messages so templates are ready for deployment.
Quick reference — Common lint error types
| Error type | Symptom | Typical fix |
|---|---|---|
| Schema / required property errors (E1001, E3001) | Missing top-level keys or wrong YAML structure | Fix YAML indentation and required key names (e.g., Resources) |
| Unknown resource property | Property name misspelled or not valid for the resource | Correct the property name or consult the resource schema |
| Type mismatch | Value type not expected (string vs object) | Provide the correct data type in the template |
| Property validation | Property value out of allowed set or format | Adjust value to match the CloudFormation resource specification |
Best practices
- Run cfn-lint as part of your local development workflow and CI pipelines to catch issues early.
- Combine cfn-lint with template formatting tools (like
prettierfor YAML or an editor extension) to keep templates consistent. - Refer to the CloudFormation resource specification when a property is unclear.
Summary
- Install cfn-lint via pip in your development environment.
- Restart VS Code after installation if needed.
- Run cfn-lint against each template (example:
cfn-lint s3-bucket.yaml). - Fix indentation, spelling, and schema issues the linter reports.
- Repeat linting until the command completes without errors, indicating the template is valid and ready for CloudFormation.