AWS SAM YAML template - Unknown Tag !Ref
Solution 1:
You can add custom YAML tags in your settings.json
:
"yaml.customTags": [
"!Equals sequence",
"!FindInMap sequence",
"!GetAtt",
"!GetAZs",
"!ImportValue",
"!Join sequence",
"!Ref",
"!Select sequence",
"!Split sequence",
"!Sub"
]
Solution 2:
First validate your extensions, I eliminated the extension called Redhat yaml and problems solved, I have the next extensions and everything is ok.
- vscode-cfn-lint
- Serverless IDE
- aws-cloudformation-yaml
- AWS Toolkit for Visual Studio Code
Solution 3:
This error message is almost certainly a false-positive from the YAML parser your IDE is using. To assess the correctness of the AWS SAM template, you should use cfn-python-lint instead, which comes with plugins for most major IDEs (unfortunately not for Visual Studio, but for Visual Studio Code).
Solution 4:
The CloudFormation Visual Studio Code extension should manage these tags for you
Solution 5:
The Ansible extension for Visual Studio Code was causing this error message for me. I removed it, and that solved the problem for my situation.