1

AWS sam build failing after adding SnapStart property in function yaml file.

 [InvalidResourceException('MyFunSnapstart', 'property SnapStart not defined for resource of type AWS::Serverless::Function'), InvalidResourceException('MyFunLamdaFunSnapstart', 'property SnapStart not defined for resource of type AWS::Serverless::Function')] ('MyFunSnapstart', 'property SnapStart not defined for resource of type AWS::Serverless::Function') ('MyFunSnapstart', 'property SnapStart not defined for resource of type AWS::Serverless::Function')

template.yaml file code:

  MyFunSnapstart:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: my-lamda-fun
      Handler: com.poc.lambda.handler.MyLambda::handleRequest
      Role: !GetAtt LambdaExecutionRole.Arn
      SnapStart:
        ApplyOn: PublishedVersions
      Events:
        MyEvent:
          Type: Api
          Properties:
            Path: /api/snapstart/hello
            RestApiId: !Ref MyRestApi
            Method: GET

My sam cli version is : SAM CLI, version 1.65.0

Ajay
  • 81
  • 8

1 Answers1

2

SAM CLI actually released version 1.66 around an hour ago with support for this new property: https://github.com/aws/aws-sam-cli/releases/tag/v1.66.0 (and PyPI), so if you update now it should work correctly.

Renato
  • 470
  • 12
  • 21
  • I just checked the sam cli release notes and updated to 1.66.0. Build is working fine. Thank you. – Ajay Nov 29 '22 at 17:22
  • How to publish lambda function through sam template.yaml ? Just putting above configuration doesn't make SnapStart to work – Ajay Dec 04 '22 at 13:30
  • 1
    After you create a version, you need to publish a version. SnapStart works on versions. SAM has a "AutoPublishAlias" property where you specify an alias name, and SAM will publish a version and point an alias to it. That works for SnapStart enabled functions – Renato Dec 05 '22 at 21:42