AWS Lambda实例启动错误

时间:2017-06-24 08:51:06

标签: amazon-web-services aws-lambda boto3

所以即时尝试创建一个lambda函数,它会在现在发生S3 PUT时触发它似乎正在执行代码但是我遇到了问题

import boto3


def lambda_handler(event, context):
    instances = ["i-0b5d926"]
    region = 'ap-south-1a'

    ec2 = boto3.client('ec2',, region_name=region)
    ec2.instances.filter(InstanceIds=instances ).start()

我收到此错误

{
  "stackTrace": [
    [
      "/var/task/index.py",
      9,
      "lambda_handler",
      "return ec2.instances.filter(InstanceIds=instaces).start()"
    ],
    [
      "/var/runtime/botocore/client.py",
      509,
      "__getattr__",
      "self.__class__.__name__, item)"
    ]
  ],
  "errorType": "AttributeError",
  "errorMessage": "'EC2' object has no attribute 'instances'"
}

任何帮助将不胜感激

ON侧注IAMROLE具有完整的Access(S3,EC2,Lambda)将在稍后配置用于特定用途

1 个答案:

答案 0 :(得分:0)

好的,我理解错误

实例为null  我变了 ec2.instances.filter(InstanceIds = instances).start() 至 ec2.start_instances(InstanceIds =实例) 并开始