Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAM/CFN json schema: handle of intrinsic functions #2596

Open
jpinkney-aws opened this issue Apr 26, 2022 · 3 comments
Open

SAM/CFN json schema: handle of intrinsic functions #2596

jpinkney-aws opened this issue Apr 26, 2022 · 3 comments
Labels
aws-documents AWS-specific programming languages, DSLs, filetypes, LSP, JSON schema aws-documents-sam-cfn LSP or JSON schema for CFN/SAM template yaml/json files feature-request New feature or enhancement. May require GitHub community feedback.

Comments

@jpinkney-aws
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Right now when we use intrinsic functions in YAML we often get error messages such as:
Incorrect type. Expected "string".

E.g.

AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Resources:
  sample:
    Type: AWS::Logs::MetricFilter
    Properties:
      LogGroupName: !Join [ ":", [ a, b, c ] ] <- Incorrect type. Expected "string"

from #1974 (comment).

This issue can also be seen a couple times in: #1978.

We should work on improving support for intrinsic functions (either in this extension or through VSCode-YAML) so that all YAML is successfully validated.

Describe the solution you'd like
There's a couple quick ideas that might help:

  1. Work with VSCode-YAML to create an API to disable validation when it sees certain intrinsic types
  2. Work with VSCode-YAML to create an API to allow us to provide custom validation on intrinsic values. This means we would be able to validate whether or not an intrinsic function is behaving correctly and provide feedback to YAML writers if there might be an error

Describe alternatives you've considered
See if we can somehow handle intrinsic functions better through this extension

Additional context
Intrinsic function reference: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html

@jpinkney-aws jpinkney-aws added the feature-request New feature or enhancement. May require GitHub community feedback. label Apr 26, 2022
@justinmk3 justinmk3 added the aws-documents-sam-cfn LSP or JSON schema for CFN/SAM template yaml/json files label Apr 26, 2022
@justinmk3 justinmk3 changed the title Improve handling of intrinsic functions in YAML SAM/CFN json schema: handle of intrinsic functions May 4, 2022
@rlucredio
Copy link

Hello guys. Please, is there any workaround that can be done in the meantime?
My config:

@justinmk3
Copy link
Contributor

justinmk3 commented Oct 5, 2022

Workarounds

Current known workarounds:

  1. install the cfn-lint vscode extension: https://github.com/aws-cloudformation/cfn-lint-visual-studio-code
  2. manually set the schema (per-file) as described in SAM json schema: cannot change schema in template.yaml file #3012 (comment)

@amandalishus
Copy link

I just installed the cfn-lint VSCode extension today, and I've tried a few different ways of updating my "yaml.customTags" setting, but I'm still seeing many problems with this. One easily reproducing option is to declare a parameter of type CommaSeparatedValues and then use Fn::Select (or !Select) on it. However, it also seems that any time I use a function within a function (i.e. !ImportValue !Sub "${Environment}-value") it finds some way to make it annoying if not impossible. I know there are a lot of different combinations when it comes to using two functions, but it seems like a lot of these problems would be helped if we could declare a return type for functions when they're defined in "yaml.customTags". Just a thought... you're the pros :)

@aws aws deleted a comment from werebear73 May 12, 2023
@justinmk3 justinmk3 added the aws-documents AWS-specific programming languages, DSLs, filetypes, LSP, JSON schema label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws-documents AWS-specific programming languages, DSLs, filetypes, LSP, JSON schema aws-documents-sam-cfn LSP or JSON schema for CFN/SAM template yaml/json files feature-request New feature or enhancement. May require GitHub community feedback.
Projects
None yet
Development

No branches or pull requests

4 participants