How to create an ec2 instance using boto3

MikA picture MikA · Sep 30, 2015 · Viewed 49.5k times · Source

Is it possible to create an ec2 instance using boto3 in python? Boto3 document is not helping here, and I couldn't find any helping documents online. please provide some sample codes/links.

Answer

gbs picture gbs · Sep 30, 2015

The API has changed but it's right there in the documentation

# Boto 3
ec2.create_instances(ImageId='<ami-image-id>', MinCount=1, MaxCount=5)

Link to the documentation: http://boto3.readthedocs.org/en/latest/guide/migrationec2.html#launching-new-instances