skip to Main Content

enter image description here

I’m using Visual Studio 2022 (Not VS Code). When editing AWS CloudFormation templates in the yaml format, Visual Studio highlights the intrinsic functions like !Ref and !Sub as syntax errors. In the list of errors, the message given is Unresolved tag:!Sub. I have already installed the AWS Toolkit for Visual Studio and it does provide Intellisense suggestions when editing the yaml file, but still flags the intrinsic functions as errors. All the solutions I can find for this problem only apply to VS Code, or to templates in the JSON format.

I have also tried adding the comment at the top of the file with the schema information.
# yaml-language-server: $schema=https://raw.githubusercontent.com/awslabs/goformation/master/schema/cloudformation.schema.json.
This gives some recommendations for missing properties but still flags !Ref, !Sub, etc. as syntax errors.

Does anybody know how to configure Visual Studio 2022 so it recognizes the CloudFormation intrinsic functions and does not flag them as errors?

2

Answers


  1. I think you need to configure the !Ref as yaml custom tag in your VS settings.json for it to avoid showing the error message

    "yaml.customTags": [
      "!Ref"
    ]
    
    Login or Signup to reply.
  2. In your vscode settings.json:

    {
        "yaml.customTags": [
            "!Base64 scalar",
            "!Cidr scalar",
            "!And sequence",
            "!Equals sequence",
            "!If sequence",
            "!Not sequence",
            "!Or sequence",
            "!Condition scalar",
            "!FindInMap sequence",
            "!GetAtt scalar",
            "!GetAtt sequence",
            "!GetAZs scalar",
            "!ImportValue scalar",
            "!Join sequence",
            "!Select sequence",
            "!Split sequence",
            "!Sub scalar",
            "!Transform mapping",
            "!Ref scalar",
        ]
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search