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 909 views
Can you give the details of the work you have done till now?

1 answer to this question.

0 votes
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
• 57,550 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
+13 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,420 points
600 views
0 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
• 57,550 points
389 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,630 points
5,300 views