How to create subnets in a vpc and in subnet 1 create Ec2 and in subnet 2 create Rds using boto3

0 votes
How to create subnets in a vpc and in subnet 1 create Ec2 and in subnet 2 create Rds using boto3
Aug 28, 2019 in AWS by pranaya
1,197 views

1 answer to this question.

0 votes

To create the subnet in VPC:

subnet = c.create_subnet(vpc.id, '10.0.0.0/25')
subnet.id
u'subnet-xxxxxx'
subnet.state
u'pending'
subnet.cidr_block
u'10.0.0.0/25'
subnet.available_ip_address_count
123
subnet.availability_zone
u'us-east-1b'

Create an ec2 instance on that subnet:

instances = ec2.create_instances(
    ImageId='ami-835b4efa', InstanceType='t2.micro', MaxCount=1, MinCount=1,
    NetworkInterfaces=[{'SubnetId': subnet.id, 'DeviceIndex': 0, 'AssociatePublicIpAddress': True, 'Groups': [sec_group.group_id]}])
instances[0].wait_until_running()
print(instances[0].id)

Have a look at this for creating rds using boto

https://gist.github.com/ikai/c79be091f98da1b709ee

answered Aug 28, 2019 by Yesha

Related Questions In AWS

0 votes
1 answer

How to create subnets in a vpc using boto3?

Here is the simple way of implementing ...READ MORE

answered Dec 5, 2018 in AWS by Shuvodip Ghosh
4,057 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
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

What are branches in AWS CodeCommit and how to create one?

To create branches, click on Branches on ...READ MORE

answered Jun 13, 2019 in AWS by Trisha
1,028 views
0 votes
1 answer

How to create an EC2 instance using Python?

Hey JunDevOps, Have a look these scripts: 1. ...READ MORE

answered Jun 24, 2019 in AWS by Aysha

edited Jun 25, 2019 8,739 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