Python &引用;errorType";:&引用;属性错误“&引用;errorMessage";:&引用';ec2.实例集合';对象没有属性';启动'&引用;
我得到以下错误:Python &引用;errorType";:&引用;属性错误“&引用;errorMessage";:&引用';ec2.实例集合';对象没有属性';启动'&引用;,python,amazon-web-services,aws-lambda,boto3,Python,Amazon Web Services,Aws Lambda,Boto3,我得到以下错误: "errorType": "AttributeError", "errorMessage": "'ec2.instancesCollection' object has no attribute 'startup'" 我不知道为什么,我知道我肯定会选择过滤器 代码在我看来是正确的。我有完全相同的代码,但用于启动我的实例,它工作得非常完美 我想这可能是因为脚本中的“启动”部分,但我不确定 守则: #define connection ec2 = boto3.resource('
"errorType": "AttributeError", "errorMessage": "'ec2.instancesCollection' object has no attribute 'startup'"
我不知道为什么,我知道我肯定会选择过滤器
代码在我看来是正确的。我有完全相同的代码,但用于启动我的实例,它工作得非常完美
我想这可能是因为脚本中的“启动”部分,但我不确定
守则:
#define connection
ec2 = boto3.resource('ec2')
def lambda_handler(event, context):
# Use the filter() method of the instances collection to retrieve
# all shutdown EC2 instances.
filters = [{
'Name': 'tag:NightlyShutdown',
'Values': ['True']
},
{
'Name': 'instance-state-name',
'Values': ['stopped']
}
]
#filter the instances
instances = ec2.instances.filter(Filters=filters)
#locate all running instances
DownInstances = [instance.id for instance in instances]
#print the instances for logging purposes
#print DownInstances
#make sure there are actually instances to start.
if len(DownInstances) > 0:
#perform the shutdown
startingUp = ec2.instances.filter(InstanceIds=DownInstances).startup()
print StartingUp
else:
print "Nothing to see here"
start()不是startup。就是这样,谢谢start()不是startup。就是这样,谢谢