serverless-ide-vscode
serverless-ide-vscode copied to clipboard
Incorrectly classifies !Ref and !GetAtt as an unknown tag in serverless
-
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](https://user-images.githubusercontent.com/7361428/87359435-af30d700-c55f-11ea-90d2-8be1723674ce.png)
-
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
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,
Thanks for reporting @Ankcorn! As @BrutalSimplicity mentioned, it's an issue with vscode yaml plugin. The solution above should solve the problem.
It works thanks both of you
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;
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 Here's where it is on my machine: c:/Users/{name}/AppData/Roaming/Code/User/settings.json
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
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](https://user-images.githubusercontent.com/8979400/223621190-2e0c3876-d89f-43ec-8dc0-118b33f71fdd.png)
@mo-martinwilson suggestion fixed it for me.
Solution: change the line to: "!GetAtt sequence"