Skip to Content
Hybrid Cloud for Developers
book

Hybrid Cloud for Developers

by Manoj Hirway
April 2018
Intermediate to advanced content levelIntermediate to advanced
280 pages
8h 37m
English
Packt Publishing
Content preview from Hybrid Cloud for Developers

Launching an EC2 instance in Python

Launching an EC2 instance using the Python boto3 library hardly takes a few lines of code. You only have to create an instance of the ec2 type using the resource() function of the boto3 library and invoke its create_instances() function. This function takes parameters specific to the instance such as Amazon Machine Image identified, key name, instance type, and so on.

The following simple program will launch the AWS EC2 instance:

import boto3ec2 = boto3.resource('ec2')instance = ec2.create_instances(    ImageId='ami-bf4193c7',    MinCount=1,    MaxCount=1,    KeyName="access",    InstanceType='t1.micro')print instance[0].id

Note that the Amazon Machine Image that you specify in the program should be present in the same ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hybrid Cloud for Architects

Hybrid Cloud for Architects

Alok Shrivastwa
OpenStack: Building a Cloud Environment

OpenStack: Building a Cloud Environment

Alok Shrivastwa, Sunil Sarat, Kevin Jackson, Cody Bunch, Egle Sigler, Tony Campbell

Publisher Resources

ISBN: 9781788830874Supplemental Content