-
Notifications
You must be signed in to change notification settings - Fork 483
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
!Sub not supported in template file #718
Comments
Hi @tmay57, Good morning. From what I see in the Description, the syntax if for the YAML template. This is different from the JSON syntax. Please let me know the exact reproduction steps and the JSON template content. Some helpful links: Thanks, |
Ashish,
The Json form is Fn::Sub. Please read the AWS docs for Intrinsic functions here https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html which shows the function syntax for both Json and YAML.
The reproduction steps are simple – just create the blogger project and add any Fn::Sub: to the template (expressed in either JSON or YAML). For instance, you can assign a description using the replacement value AWS::StackName. { “Fn::Sub” : “${AWS::StackName}” } or Fn::Sub: ${AWS::StackName”}
Remember that the purpose of the Fn::Sub intrinsic function is to resolve resource references we can’t know until the template is being processed by Could Formation. Thus, only the most trivial of serverless templates are currently possible in the extension.
FWIW, the extension does process either yaml or JSON templates. I read through the source for the extension and then converted the Blogger serverless.template from JSON to YAML form to test this. Remember that JSON is a subset of YAML and that is the rational for use YAML as the primary format here (comments etc.).
In general, I would expect the extension to be as capable as the SAM CLI in processing valid SAM templates. Please let us know if this is not the target feature set you are shooting for.
Cheers,
Tim
From: Ashish Dhingra <[email protected]>
Sent: Monday, August 17, 2020 10:15 AM
To: aws/aws-lambda-dotnet <[email protected]>
Cc: Timothy May <[email protected]>; Mention <[email protected]>
Subject: Re: [aws/aws-lambda-dotnet] !Sub not supported in template file (#718)
Hi @tmay57<https://github.com/tmay57>,
Good morning.
From what I see in the Description, the syntax if for the YAML template. This is different from the JSON syntax. Please let me know the exact reproduction steps and the JSON template content.
Thanks,
Ashish
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#718 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AIO4MK5AD4BMPOIVX6G4YSDSBFQRTANCNFSM4QAJW7XQ>.
|
Hi @tmay57, Thanks for your inputs. Although its evident but just want to confirm if you are using AWS Toolkit for Visual Studio. Based on your confirmation we would need to move it to proper repository aws/aws-toolkit-visual-studio. Thanks, |
Ashish,
Sorry – yes, I’m using AWS Toolkit for Visual Studio.
Thanks!
Tim
From: Ashish Dhingra <[email protected]>
Sent: Tuesday, August 18, 2020 9:29 AM
To: aws/aws-lambda-dotnet <[email protected]>
Cc: Timothy May <[email protected]>; Mention <[email protected]>
Subject: Re: [aws/aws-lambda-dotnet] !Sub not supported in template file (#718)
Hi @tmay57<https://github.com/tmay57>,
Thanks for your inputs. Although its evident but just want to confirm if you are using AWS Toolkit for Visual Studio. Based on your confirmation we would need to move it to proper repository aws/aws-toolkit-visual-studio<https://github.com/aws/aws-toolkit-visual-studio>.
Thanks,
Ashish
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#718 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AIO4MK4BHV3KHGBJCAUBLGDSBKT33ANCNFSM4QAJW7XQ>.
|
@tmay57 Thanks for your reply. I will have developer look at it, but it could be a while until fix is implemented since we need to ensure backward compatibility, etc. Thanks, |
@tmay57 I can confirm that short form YAML
However, I was able to use full form JSON
YAML
Therefore, I would suggest you to use full form Let me know if you are still blocked. Also, as an additional check, you can verify your cloud formation template using validate-template. Make sure you prefix your template file path with |
Thanks for the update. A few notes:
I was able to get the following form, based on your example, to work:
Note the single quotes are not included. There is no need to single quote either the Fn::Sub or the string value. Single quotes are added to the string value only if it contains characters that could be interpreted as yaml special characters. Since the form without single quotes worked, my assumption is that your parser is not depending on them unless required per yaml parsing specifications.
I see a lot of the single line form so it may be worth figuring that out as well so folks used to editing templates in yaml don't get frustrated by differences between SAM CLI and VS Toolkit yaml file processing. In our case we generate pretty much the entire serverless.template file from meta-data so I can change the emitter to use the Fn::Sub style naming and multi-line form. However, these generated templates may be subsequently updated by humans so we will have to beef up our docs to tell users to ignore the AWS docs on intrinsic functions until this gets resolved. We are not blocked and will just update our generators and docs to play pretty with the VS Toolkit. Thank you for your quick reply. |
VS Toolkit uses YamlDotNet for parsing YAML document and it doesn't support short form of intrinsic functions i.e. I have created an issue in YamlDotNet repository and as well as a backlog item in our queue. |
FWIW, we also use YamlDotNet and have no problem with parsing the intrinsic functions. However, we did have a bit of head scratching to get the following emitter form to work: |
We have noticed this issue has not recieved attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue. |
We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue. |
Description
Generates an error: Error parsing JSON CloudFormation Template. ... : Exception during deserialization
Using Fn::Sub: also fails.
This is true for both JSON and Yaml template file formats.
Reproduction Steps
Create the sample Blogger application. Add the FunctionName property as shown above. Try to publish.
BTW - using the SAM CLI works just fine as does Stackery.io. My assumption is that any template that is valid for the SAM CLI should be valid with the VS extension.
Logs
NA
Environment
Resolution
This is a 🐛 bug-report
The text was updated successfully, but these errors were encountered: