I am writing this lambda in Python boto3 sdk in AWS. All I am trying to do is bring up all the ec2 instances. After adding all the instances to a List, I am able print all the list of instances. I am using EC2 waiter to wait until all instances come up.
It throws a message saying parametervalidation error at this line: "waiter.wait(InstanceIds=all_instance_ids)"
import json
import boto3
def lambda_handler(event, context):
aws_mgmt_console = boto3.session.Session()
ec2_console_resource = aws_mgmt_console.resource('ec2')
ec2_console_client = aws_mgmt_console.client('ec2')
#starting all instances at the same time
#First step get the list of all instances
all_instance_ids=[]
for each_instance in ec2_console_resource.instances.all():
all_instance_ids.append(each_instance)
#step 2 create a waiter
waiter=ec2_console_client.get_waiter('instance_running')
waiter.wait(InstanceIds=all_instance_ids)
print("All Your ec2 instace are up and running")
"errorMessage": "Parameter validation failed:\nInvalid type for parameter InstanceIds[0], value: ec2.Instance(id='i-06a380ffcdb0581c6'), type: <class 'boto3.resources.factory.ec2.Instance'>, valid types: <class 'str'>\nInvalid type for parameter InstanceIds[1], value: ec2.Instance(id='i-069263b1d8fae9b87'), type: <class 'boto3.resources.factory.ec2.Instance'>, valid types: <class 'str'>", "errorType": "ParamValidationError", "requestId": "beb371b8-fa82-4274-8244-415341bef376", "stackTrace": [ " File "/var/task/lambda_function.py", line 38, in lambda_handler\n waiter.wait(InstanceIds=all_instance_ids) #40 checks after every 15 sec\n",