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 in AWS by akhtar
• 33,470 points
29 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 by MD
• 79,390 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
938 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 in AWS by MD
• 79,390 points
120 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 in AWS by MD
• 79,390 points
51 views