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, 2020 in AWS by akhtar
• 38,230 points
868 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, 2020 by MD
• 95,440 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
• 58,090 points
1,372 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, 2020 in AWS by MD
• 95,440 points
1,403 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 11, 2020 in AWS by MD
• 95,440 points
2,128 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,670 points
1,235 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 11, 2020 in AWS by MD
• 95,440 points
3,773 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, 2020 in AWS by MD
• 95,440 points
1,649 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