amazon-web-servicesaws-cloudformationaws-serverless

The term 'Events:' is not recognized in cloudformation template in AWS


I am trying my hands on SAM serverless framework. Been following a tutorial. Steps i followed

  1. Created a SAM template.
  2. Converted the SAM template into cloud formation template and stored it in S3
  3. Tried to deploy the cloud formation template that was generated from the conversion.

Below is the converted cloud formation template:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Demo For SAM !!!
Globals:
  Function:
    MemorySize: 128
    Runtime: Python 3.6
    Timeout: 5
Resources:
  display:
    Type: AWS::Serverless::Function
    Properties:
      Handler: display.lambda_handler
      Events:
        GetLogs:
          Type: Api
          Properties:
            Path: /call
            Method: get
      CodeUri: s3://sumanth-sam/debb239335f6dcf3f3f146367295b556
  add:
    Type: AWS::Serverless::Function
    Properties:
      Handler: add.lambda_handler
      Events:
        Add:
          Type: Api
          Properties:
            Path: /add
            Method: post
      CodeUri: s3://sumanth-sam/debb239335f6dcf3f3f146367295b556

Cloud formation stack is going into Roll-back for following error.

Events:
Events: : The term 'Events:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was  
included, verify that the path is correct and try again.
At line:1 char:1
+ Events:
+ ~~~~~~~
    + FullyQualifiedErrorId : CommandNotFoundException
 
PS C:\Users\asus\OneDrive\Desktop\SAM\sam_demo>         GetLogs:
GetLogs: : The term 'GetLogs:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path    
was included, verify that the path is correct and try again.
At line:1 char:9
+         GetLogs:
+         ~~~~~~~~
    + FullyQualifiedErrorId : CommandNotFoundException
 
PS C:\Users\asus\OneDrive\Desktop\SAM\sam_demo>           Type: Api
Type: : The term 'Type:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was      
included, verify that the path is correct and try again.
At line:1 char:11
+           Type: Api
+           ~~~~~
    + FullyQualifiedErrorId : CommandNotFoundException
 
PS C:\Users\asus\OneDrive\Desktop\SAM\sam_demo>           Properties:
Properties: : The term 'Properties:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a   
path was included, verify that the path is correct and try again.
At line:1 char:11
+           Properties:
+           ~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Properties::String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
 
PS C:\Users\asus\OneDrive\Desktop\SAM\sam_demo>             Path: /call
Path: : The term 'Path:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was 
included, verify that the path is correct and try again.
At line:1 char:13
+             Path: /call
+             ~~~~~
    + CategoryInfo          : ObjectNotFound: (Path::String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I feel the issue might be with the structure of the template(not able to pinpoint). Or i might me using some outdated approach. Could anyone help me out of this.


Solution

  • CloudFormation Linter in VSCode shows errors inline while authoring templates along with autocompletion and documentation links:

    E3030 You must specify a valid value for Runtime (Python 3.6).
    Valid values are ["dotnetcore1.0", "dotnetcore2.0", "dotnetcore2.1", "dotnetcore3.1", "go1.x", "java8", "java8.al2", "java11", "nodejs", "nodejs4.3-edge", "nodejs4.3", "nodejs6.10", "nodejs8.10", "nodejs10.x", "nodejs12.x", "provided", "provided.al2", "python2.7", "python3.6", "python3.7", "python3.8", "ruby2.5", "ruby2.7"]