How to Pass the VPC ID while creating the Ec2 instance in AWS using Python Boto3

0 votes
Jan 25, 2019 in AWS by anonymous

recategorized Jan 25, 2019 by Vardhan 2,915 views
Can you give the details of the work you have done till now?

1 answer to this question.

+1 vote
import boto3
ec2 = boto3.resource('ec2')
instance = ec2.create_instances(
    ImageId = 'ami-009d6802948d06e52',
    MinCount = 1,
    MaxCount = 1,
    InstanceType = 't2.micro',
    KeyName = 'keyfilename',
    SubnetId = 'subnet-02f498277')
print (instance[0].id)
answered Jan 29, 2019 by Priyaj
• 58,090 points
how to mention our aws credetial

Hii rajesh,

For your query you can refer this-https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html

Hope it is helpfull!!

Thank you!!

Hi@rajesh

You don't need to set your credentials. You are trying to connect your AWS via boto3. In this case, you are using your private key.
Hii nirojj,
I'm new in aws so can you please provide me similar documentation course from where to start with aws

Hello @Aryan,

As you want to get started with AWS you can refer to this blog:What is AWS ? – An Introduction to AWS

You can also check out the course of AWS:https://www.edureka.co/aws-developer-certification-training

Hope it is helpful!!

Thank you!!

Related Questions In AWS

0 votes
1 answer

How to create an AWS EC2 Instance in the VPC with Boto3 module?

Hi@akhtar, You can use a network interface in ...READ MORE

answered Oct 11, 2020 in AWS by MD
• 95,440 points
2,096 views
0 votes
1 answer
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,439 views
+2 votes
1 answer
0 votes
1 answer

Pass account id of an AWS sub account using a variable as an argument in CloudWatch Alarm Actions with python (boto3)?

Python String and Integer concatenation >>> print("arn:aws:swf:us-east-2:{0}:action/actions/AWS_EC2.InstanceId.Stop/1.0".format(acccnum)) arn:aws:swf:us-east-2:12312312312312:action/actions/AWS_EC2.InstanceId.Stop/1.0 >>> print("arn:aws:swf:us-east-2:" ...READ MORE

answered Oct 5, 2018 in AWS by Priyaj
• 58,090 points
1,353 views
+1 vote
2 answers

How do I run python script on aws EC2 instance(ubuntu)?

I believe that you are using the ...READ MORE

answered Apr 17, 2018 in AWS by Cloud gunner
• 4,670 points
9,893 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP