Getting error while deleting my VPC

0 votes
AttributeError: 'ec2.ServiceResource' object has no attribute 'delete_vpc'

This is the error I am getting.

I am using the following code:

import boto3
ec2 = boto3.resource('ec2')
ec2client.delete_vpc(VpcId = 'vpc-id')

Can someone help me with this?

Dec 4, 2018 in AWS by Kanishk
• 890 points
1,224 views

1 answer to this question.

0 votes

This is the code to delete the VPC. Make sure you don't delete the default VPC as it is created by Amazon and can't be recreated by you.

import boto3
ec2 = boto3.resource('ec2')
ec2client = ec2.meta.client
ec2client.delete_vpc(VpcId = 'vpc-id')

This way you can delete the vpc. Hope this helps

answered Dec 4, 2018 by Shuvodip Ghosh

Related Questions In AWS

0 votes
1 answer

Getting Error 503 when I using my site via DNS

add the server_name directive to your Nginx ...READ MORE

answered Apr 25, 2018 in AWS by Cloud gunner
• 4,670 points
1,913 views
0 votes
1 answer

Getting connection timed while connecting to my EC2 instance

Due to some technical difficulties on the ...READ MORE

answered Dec 14, 2018 in AWS by Aniket
2,135 views
0 votes
1 answer
0 votes
1 answer

AWS S3 CLI : error while trying to copy files locally using terminal

For the first error you should add ...READ MORE

answered Aug 3, 2018 in AWS by Archana
• 4,170 points
11,491 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to delete a VPC using boto3?

You can view this answer here : https://www.edureka.co/community/32160/getting-error-while-deleting-my-vpc Before ...READ MORE

answered Dec 4, 2018 in AWS by Shuvodip Ghosh
2,728 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