serverless-ide-vscode icon indicating copy to clipboard operation
serverless-ide-vscode copied to clipboard

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

Open Ankcorn opened this issue 4 years ago • 7 comments

  • I'm submitting a ...

    • ✅ bug report
    • [ ] feature request
    • [ ] support request => Please do not submit support request here, see note at the top of this template.
  • What is the current behavior?

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

image
  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://github.com/Ankcorn/serverless-fullstack-example-app You can test this yml is acceptable by deploying this stack

  • What is the expected behavior? Serverless IDE allows !Ref and !GetAtt where the target is a Resource

  • What is the motivation/use case for changing the behavior?

More concise and easy to type yml files

  • Please tell us about your environment:

    • Plugin version 0.5.24
    • VSCode version 1.4.7
    • Template type Serverless Framework

Ankcorn avatar Jul 14 '20 08:07 Ankcorn

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,

BrutalSimplicity avatar Jul 21 '20 04:07 BrutalSimplicity

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

pavelvlasov avatar Jul 25 '20 06:07 pavelvlasov

It works thanks both of you

Ankcorn avatar Jul 25 '20 08:07 Ankcorn

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.

Swaps76 avatar Jul 30 '21 10:07 Swaps76

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

outspokeio avatar Dec 12 '21 19:12 outspokeio

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

mo-martinwilson avatar Jan 13 '23 12:01 mo-martinwilson

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"

joshuakcockrell avatar Mar 08 '23 04:03 joshuakcockrell