AWS::Lambda::Function is NOT Supported

about AWS::Lambda::Function, based on http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html

and it looks serverless framework does NOT support Method definition in resource but only in functions block

for example: let’s say if we have defined functions block as below which works fine

functions:
  getToken:
    handler: index.getToken
    name: getToken
    memorySize: 256

Then use the new Method in resource to replace above definition ( remove above from yml file)

resource
 Resources:
   getToken: 
      Type: "AWS::Lambda::Function"
      Properties: 
        Handler: "index.getToken"
        MemorySize: 256
        Role: 
          Fn::GetAtt: 
            - "LambdaExecutionRole"
            - "Arn"
        Code: 
          S3Bucket: "yourbucketofDeployment"
          S3Key: "service1.zip"
        Runtime: ${self:provider.runtime}
        Timeout: 25
        TracingConfig:
          Mode: "Active"

try to run sls deploy --alias dev , you get Cannot read property ‘Properties’ of undefined error all the time unless you revert it back to functions structure as before the old way.

Simply tested and say if we remove functions block from yml file , it throws this error all the time . are we stuck at this structure?

Is that your actual resources section? The indentation is not right in the code you’ve pasted (Resources should be 2 spaces in).

You definitely can define functions you the resources block, it’s just CloudFormation.