Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services &引用;处理程序';lambda#u handler';模块上缺少';lambda#u函数&x27&引用;_Amazon Web Services_Aws Lambda - Fatal编程技术网

Amazon web services &引用;处理程序';lambda#u handler';模块上缺少';lambda#u函数&x27&引用;

Amazon web services &引用;处理程序';lambda#u handler';模块上缺少';lambda#u函数&x27&引用;,amazon-web-services,aws-lambda,Amazon Web Services,Aws Lambda,下面是我得到的代码和错误。。我需要帮助 import boto3 ec2_client=boto3.client('ec2') ec2_client.create_tags(Resources=['i-01d90bb1c3a45708b'], Tags=[{'Key':'Testing', 'Value':'TestingBySwamy'}]) 答复: { "errorMessage": "Handler 'lambda_handler' missing on modul

下面是我得到的代码和错误。。我需要帮助

import boto3

    ec2_client=boto3.client('ec2')
    ec2_client.create_tags(Resources=['i-01d90bb1c3a45708b'], Tags=[{'Key':'Testing', 'Value':'TestingBySwamy'}])
答复:

{
  "errorMessage": "Handler 'lambda_handler' missing on module 'lambda_function'"
}
Handler 'lambda_handler' missing on module 'lambda_function': module 'lambda_function' has no attribute 'lambda_handler'

在lambda中运行代码时,它具有以下语法:

def handler_name(event, context): 
    // paste your code here
    return some_value
在您的情况下,请尝试以下操作:

import boto3

def handler_name(event, context): 
    ec2_client=boto3.client('ec2')
    ec2_client.create_tags(Resources=['i-01d90bb1c3a45708b'], Tags=[{'Key':'Testing', 'Value':'TestingBySwamy'}])
请参阅:

的可能副本看起来像的副本。请尝试将代码放在名为lambda_handler的函数下