I'm using AWS Lambda to turn on\off EC2 instances at a specified intervals vai CloudWatch. I write AWS Lambda code using Python 2.7 runtime and put the code:
import boto3
region = 'xxxxxx'
instances = ['i-xxxxxxxxxx']
def lambda_handler(event, context):
ec2 = boto3.client('ec2', region_name=region)
ec2.stop_instances(InstanceIds=instances)
print 'stopped your instances: ' + str(instances)
As the inline code. But I want to test the stopping of EC2 instance by manually trigger the lambda function where I get the following error in the execution log:
{
"errorMessage": "Handler 'handler' missing on module 'index'"
}
Anyone help would be appreciated.