3

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'
2

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.