threadheap / serverless-ide-vscode

Serverless IDE: Enhanced support for AWS SAM and CloudFormation in VS Code
https://serverless-ide.com/
195 stars 45 forks source link

Incorrectly classifies !Ref and !GetAtt as an unknown tag in serverless #93

Open Ankcorn opened 4 years ago

Ankcorn commented 4 years ago

This tool incorrectly classifies !Ref and !GetAtt as an unknown tag in serverless

image

More concise and easy to type yml files

BrutalSimplicity commented 4 years ago

I think you can fix this by adding the intrinsic AWS functions as supported tags for yaml. It's not the cleanest solution as these tags will always show up in your intellisense regardless of what type of yaml file your editing, but it does get rid of the error given by the extension.

https://marketplace.visualstudio.com/items?itemName=aws-scripting-guy.cform

After installation, open your User Settings (Ctrl + ,) and paste preferences below into your settings file.

Note: This will whitelist CloudFormation intrinsic functions tags. Otherwise you will end up with Unknown Tag showing up in your YAML document.

    // Custom tags for the parser to use
    "yaml.customTags": [
        "!And",
        "!If",
        "!Not",
        "!Equals",
        "!Or",
        "!FindInMap sequence",
        "!Base64",
        "!Cidr",
        "!Ref",
        "!Sub",
        "!GetAtt",
        "!GetAZs",
        "!ImportValue",
        "!Select",
        "!Select sequence",
        "!Split",
        "!Join sequence"
    ],
    // Enable/disable default YAML formatter (requires restart)
    "yaml.format.enable": true,
pavelvlasov commented 4 years ago

Thanks for reporting @Ankcorn! As @BrutalSimplicity mentioned, it's an issue with vscode yaml plugin. The solution above should solve the problem.

Ankcorn commented 4 years ago

It works thanks both of you

Swaps76 commented 3 years ago

Hi, I can't see where to past into the file - I click cmd +, to get to preferences, and then I have the following screen; image but I can't see where to edit the 'user settings file'. Is this the default settings file or vs code settings file? I can only toggle settings in here rather than edit files. Thanks.

outspokeio commented 2 years ago

@Swaps76 Here's where it is on my machine: c:/Users/{name}/AppData/Roaming/Code/User/settings.json

mo-martinwilson commented 1 year ago

I think you can fix this by adding the intrinsic AWS functions as supported tags for yaml. It's not the cleanest solution as these tags will always show up in your intellisense regardless of what type of yaml file your editing, but it does get rid of the error given by the extension.

https://marketplace.visualstudio.com/items?itemName=aws-scripting-guy.cform

After installation, open your User Settings (Ctrl + ,) and paste preferences below into your settings file.

Note: This will whitelist CloudFormation intrinsic functions tags. Otherwise you will end up with Unknown Tag showing up in your YAML document.

    // Custom tags for the parser to use
    "yaml.customTags": [
        "!And",
        "!If",
        "!Not",
        "!Equals",
        "!Or",
        "!FindInMap sequence",
        "!Base64",
        "!Cidr",
        "!Ref",
        "!Sub",
        "!GetAtt",
        "!GetAZs",
        "!ImportValue",
        "!Select",
        "!Select sequence",
        "!Split",
        "!Join sequence"
    ],
    // Enable/disable default YAML formatter (requires restart)
    "yaml.format.enable": true,

Tha's great — thanks. The only thing I needed to change was to append sequence to !If, i.e. !If sequence

joshuakcockrell commented 1 year ago

I was encountering this error with the "!GetAtt" command, even after adding the yaml.customTags settings.

Screenshot 2023-03-07 at 9 37 50 PM

@mo-martinwilson suggestion fixed it for me. Solution: change the line to: "!GetAtt sequence"

ASalem404 commented 2 months ago

works for me, Thanks