Narayana Swamy
Narayana Swamy

Reputation: 51

"Handler 'lambda_handler' missing on module 'lambda_function'"

Below is my code and error I am getting.. I need help.

import boto3

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

Response:

{
  "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'

Upvotes: 3

Views: 12904

Answers (1)

Gowtham Chand
Gowtham Chand

Reputation: 903

When you run the code in the lambda, it has the following syntax,

def handler_name(event, context): 
    // paste your code here
    return some_value

In your case, try the following,

import boto3

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

Refer: Lambda Function Handler (Python) - AWS Lambda

Upvotes: 4

Related Questions