redhat-developer / vscode-yaml

YAML support for VS Code with built-in kubernetes syntax support
MIT License
670 stars 224 forks source link

CloudFormation ref in Fn:GetAtt and Fn:FindInMap shows validations errors Incorrect type. Expected "string". yaml-schema: aws://cloudformation.schema.json #867

Open lirem opened 1 year ago

lirem commented 1 year ago

Describe the bug

I have "Incorrect type. Expected "string".yaml-schema: aws://cloudformation.schema.json" error, but aws is working normally with this template.

Screenshot 2023-01-06 at 11 26 41 Screenshot 2023-01-06 at 11 26 04

Expected Behavior

Nothing shoud be highlighted, because it's working template

Environment

ghost commented 1 year ago

Similar problem. And to add to this I have added all of the yaml.customTags for each of other intrinsic functions of CloudFormation.

lirem commented 1 year ago

Yeah, the best way when the YAML extension still doesn't work is to use the CloudFormation Linter extension. It works very well with CloudFormation and even helps you with some errors and gives you warnings(e.g. defined but not used resources)

allenfisher commented 1 year ago

I'm seeing this as well. I'd really like this fixed, I like to use the CFN extension provided by aws-scripting-guy as I get snippets and all sorts of stuff.

paulJRCurtis commented 1 year ago

Have a look at https://github.com/redhat-developer/vscode-yaml/issues/669#issuecomment-1136338006 for a list of intrinsic functions that you can add to your settings. It's in short form but you could use the long forms listed on https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html

I use the CloudFormation short form so the above works for me but you'd need to change to the long form based on your example. That and for !GetAtt if you use the short form syntax it works.

AllocationId: !GetAtt PublicSubnet1EIP.AllocationId

I haven't yet worked out how to deal with AvailabilityZone: !Select [ 1, !GetAZs '' ] returning a Incorrect type. Expected "string" error.

TeeSeal commented 2 months ago

I am having a similar problem with:

  Api:
    Type: "AWS::Serverless::Api"
    Properties:
      Name: !Join ["-", ["foo", !Ref "bar"]]

I understand that it is not possible to infer the return type from custom tags at this time. Perhaps a way to define said return type would help? Or otherwise a way to disable validations where custom tags are used would be nice.

fushihara commented 1 month ago

I gave up and I disabled the validator by setting “yaml.validate”: false, in .vscode\settings.json It changes the color of the key and value text, so it's still better than editing directly in Notepad!