Create a subnet in AWS with Boto3.

0 votes

Hi Team,

I have created one VPC in AWS with the help of the Boto3 module. Now I want to create a subnet into this VPC. How can I do that?

Oct 10 in AWS by akhtar
• 33,470 points
25 views

1 answer to this question.

0 votes

Hi@akhtar,

After creating a VPC you need to create a subnet so that you can launch instances into that subnet. You can see the below code to create a subnet.

# create subnet and associate it with route table
subnet = ec2.create_subnet(CidrBlock='172.16.1.0/24', VpcId=vpc.id)
routetable.associate_with_subnet(SubnetId=subnet.id)
answered Oct 10 by MD
• 79,390 points

Related Questions In AWS

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,700 points
481 views
0 votes
1 answer

How to create a VPC in AWS using Boto3?

Hi@akhtar, Amazon Web Services enables you to create ...READ MORE

answered Oct 9 in AWS by MD
• 79,390 points
55 views
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 10 in AWS by MD
• 79,390 points
70 views
0 votes
1 answer
0 votes
1 answer

How can I return XML from boto calls?

I don't think there's an officially supported ...READ MORE

answered Jul 20, 2018 in AWS by Cloud gunner
• 4,650 points
402 views
0 votes
1 answer

How to create a security group in AWS with Boto3?

Hi@akhtar, You can create a new security group ...READ MORE

answered Oct 10 in AWS by MD
• 79,390 points
116 views
0 votes
1 answer

Create a key pair in AWS using Boto3.

Hi@akhtar, You need to create a 2048-bit RSA ...READ MORE

answered Oct 8 in AWS by MD
• 79,390 points
58 views