【发布时间】:2018-04-12 12:02:03
【问题描述】:
我正在使用 AWS Lambda 以指定的时间间隔通过 CloudWatch 打开/关闭 EC2 实例。我使用 Python 2.7 运行时编写 AWS Lambda 代码并放入代码:
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)
作为内联代码。但我想通过手动触发 lambda 函数来测试 EC2 实例的停止,在执行日志中出现以下错误:
{
"errorMessage": "Handler 'handler' missing on module 'index'"
}
任何人的帮助将不胜感激。
【问题讨论】:
标签: python amazon-web-services amazon-ec2 aws-lambda