简体   繁体   English

错误 Lambda 函数处理程序

[英]Error Lambda Function handler

this is my lambda function-这是我的 lambda 函数-

import boto3

def send_function(event, context):

    valu=event['VAL']
    mname=event['MNAM']
    d=boto3.client('cloudwatch')
    d.put_metric_data(Namespace='WebStatus',
        MetricData=[
            {
            'MetricName': mname,
            'Dimensions': [
                {
                'Name': 'Status',
                'Value': 'WebsiteStatusCode'
                },
            ],
            'Value': valu,
            },
        ]
    )

and i get error - "errorMessage": "Unable to import module 'lambda_function'"我收到错误 - “errorMessage”:“无法导入模块 'lambda_function'”

This error happens when you define wrong lambda handler name while you upload your lambda function.如果您在上传 lambda 函数时定义了错误的 lambda 处理程序名称,则会发生此错误。 The name of the lambda handler has to be <your python filename>.<your method name> . lambda 处理程序的名称必须是<your python filename>.<your method name>

So if your python filename is hello_python.py , the lambda handler should be defined hello_python.send_function .因此,如果您的 python 文件名是hello_python.py ,则 lambda 处理程序应定义为hello_python.send_function For more info, read this .有关更多信息,请阅读此

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM