AWS SAM template "Unresolved tag: !RefYAML"

0

Hello! I am getting this error when using !Ref in my template.yaml file for AWS SAM. I have seen some people suggest online adding this to the settings.json:

"yaml.customTags": [ "!Equals sequence", "!FindInMap sequence", "!GetAtt", "!GetAZs", "!ImportValue", "!Join sequence", "!Ref", "!Select sequence", "!Split sequence", "!Sub" ]

However, the files that SAM created for me did not include a settings.json. I added one, put an empty {} object, then added the above key / value pair. This did not resolve the !Ref error in the template.yaml file. So, how do I resolve the error? It would also be great if you could point out related documentation. Thanks.

Dlindqu
asked 6 months ago534 views
2 Answers
0

Try validating your template.yaml using the AWS SAM CLI: sam validate This can catch syntax issues.

Validating templates: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-using-validate.html

profile pictureAWS
answered 6 months ago
  • Dave- thank you for responding. Yes, when I entered the command "sam validate --template template.yaml", I got the same error that I had in the past, namely "E0001 Error transforming template: Resource with id [CounterFunction] is invalid. Policy at index 0 in the 'Policies' property is not valid". This is specifically referring to a policy: Policies: - DynamoDBCrudPolicy: TableName: !Ref CounterTable So, it shows the same error I expected. How should I fix the !Ref error?

  • Apologies for the formatting. Those lines are in my template.yaml file, with "Policies:" on one line, "- DynamoDBCrudPolicy:" on the next, and "TableName: !Ref CounterTable" on the next.

0

Hi, I think you might need to clarify your question. You started off saying the error is "Unresolved tag: !RefYAML" but then later that it's "E0001 Error transforming template: Resource with id [CounterFunction] is invalid. Policy at index 0 in the 'Policies' property is not valid" - do you have both?

You will need to provide the relevant part of your template with proper "code" formatting as white space is so important with YAML. You can do this if you post an Answer rather than a Comment here.

EXPERT
answered 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions