Unable to add code to AWS Lambda feature using CloudFormation

I am trying to create a Cloud Formation Stack. The stack has been deployed correctly. A Lambda function was created, but the code is not added as built-in to the function.

It says

The lambda function "lambda_function" cannot be edited inline because the file name specified in the handler does not match the file name in your deployment package.

Cloud Form Code:

  LambdaFunction:
    Type: "AWS::Lambda::Function"
    Properties:
      Code:
        ZipFile: !Sub |
          import json

          def lambda_handler(event,context):
              #Creating delete request
              ...

      Description: Lambda function.
      FunctionName: lambda_function
      Handler: lambda_function.lambda_handler
      Role : !GetAtt LambdaExecutionRole.Arn
      Runtime: python2.7
      Timeout: 5
+4
source share
1 answer

The first part of the handler should always be indexif you specify inline code.

, ZipFile Code, index.function_name . http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html

:

LambdaFunction:
    Type: "AWS::Lambda::Function"
    Properties:
      Code:
        ZipFile: !Sub |
          import json

          def lambda_handler(event,context):
              #Creating delete request
              ...

      Description: Lambda function.
      FunctionName: lambda_function
      Handler: index.lambda_handler
      Role : !GetAtt LambdaExecutionRole.Arn
      Runtime: python2.7
      Timeout: 5

index.lambda_handler lambda_function.lambda_handler.

+5

Source: https://habr.com/ru/post/1675703/


All Articles