How to delete a key pair using Boto3

0 votes

Hi Team,

I have created one key pair in AWS using the Boto3 module. Now I want to delete the key pair. How can I do that?

Oct 8, 2020 in AWS by akhtar
• 38,260 points
1,931 views

1 answer to this question.

0 votes

Hi@akhtar,

You can delete a key pair using the Boto3 module. For that, you need to set the AWS credentials first and then you can use the below code.

import boto3
ec2 = boto3.client('ec2')
response = ec2.delete_key_pair(KeyName='KEY_PAIR_NAME')
print(response)
answered Oct 8, 2020 by MD
• 95,460 points

Related Questions In AWS

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,732 views
0 votes
1 answer
+1 vote
2 answers
0 votes
1 answer

How to describe a key pair using Boto3?

Hi@akhtar, You can find one method in your ...READ MORE

answered Oct 8, 2020 in AWS by MD
• 95,460 points
1,582 views
0 votes
1 answer

How to delete a security group using Boto3 module?

Hi@akhtar, If you attempt to delete a security ...READ MORE

answered Oct 8, 2020 in AWS by MD
• 95,460 points
1,974 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