Create an ec2 instance using boto

0 votes
How do I create an ec2 instance in AWS using boto?
Jun 24, 2019 in Python by Neel
205 views

1 answer to this question.

0 votes

Hi @Neel, try this script:

reservations = conn.get_all_instances(instance_ids=[sys.argv[1]])
instances = [i for r in reservations for i in r.instances]
for i in instances:
    key_name = i.key_name
    security_group = i.groups[0].id
    instance_type = i.instance_type
    print "Now Spinning New Instance"
    subnet_name = i.subnet_id
    reserve = conn.run_instances(image_id=ami_id,key_name=key_name,instance_type=instance_type,security_group_ids=[security_group],subnet_id=subnet_name)
answered Jun 24, 2019 by Varsha

Related Questions In Python

0 votes
1 answer

Unable to create EC2 instance using boto3

Hi@Pradeep, I have tried the below code and ...READ MORE

answered Jul 13, 2020 in Python by MD
• 95,360 points
284 views
0 votes
0 answers
+2 votes
3 answers

How can I play an audio file in the background using Python?

down voteacceptedFor windows: you could use  winsound.SND_ASYNC to play them ...READ MORE

answered Apr 4, 2018 in Python by charlie_brown
• 7,710 points
10,895 views
+1 vote
1 answer

How to create plots using python matplotlib in IPython notebook?

I think you should try: I used %matplotlib inline in ...READ MORE

answered Aug 8, 2018 in Python by Priyaj
• 58,080 points
703 views
0 votes
1 answer

Using Shapely on AWS Lambda with Python 3

For some reason, the pip install of ...READ MORE

answered Oct 8, 2018 in AWS by Priyaj
• 58,080 points
1,565 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

SSH into an ec2 instance using boto

Hi @Neha, try something like thus: import boto3 import ...READ MORE

answered Jun 24, 2019 in Python by Varsha
2,989 views
0 votes
1 answer

Attach volume to existing ec2 instance using python

Yes of course that's possible with just ...READ MORE

answered Jun 24, 2019 in Python by Krina
870 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP