0

I'm using boto3 to create aws ec2 instances.

ec2 = boto3.resource('ec2', region_name='ap-northeast-2')
ec2.create_instances(..)

can't found async options.

Like aws lambda "InvocationType":

awslambda.invoke(FunctionName='TEST', InvocationType='Event',
                                           Payload=json.dumps(new))
pakachu
  • 77
  • 1
  • 1
  • 13

1 Answers1

1

Unfortunately there is no async function for that in the API.

If you want to ignore the result you have to do an async call in another thread, there is multiple ways to do this in python.

Note that there is an unofficial Async AWS python SDK aioboto3. It does not contain your API call today but you can contribute if you like.

xavierraffin
  • 189
  • 2
  • 8
  • But... "asynchronous" in the same sense as Lambda's `invoke(InvocationType='Event')` isn't about asynchronous handling on the client side -- it's about how when/how fast the service API returns a response. When a Lambda function is invoked asynchronously, the underlying service API itself responds immediately with success if the request is authorized, not waiting for the Lambda function to actually run to completion. Arguably, in that sense, `ec2.run_instances()` is already asynchronous -- the service responds well before the instances are actually running, which is why "waiters" are needed. – Michael - sqlbot Feb 27 '19 at 19:20