AWS CLI EC2 Cheat Sheet/Delete a key pair

Remove a key pair from the account.

Section: AMIs and Key Pairs

Delete a key pair

bash
bash
aws ec2 delete-key-pair --key-name my-key
Explanation

Does not delete any local private key file you may have saved separately.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing AMIs and Key Pairs
List key pairs
Show EC2 key pairs in the account.
OpenIn sheetbashsame section
Create a key pair
Generate a new EC2 key pair and save the private key.
OpenIn sheetbashsame section
Describe AMIs
List AMIs visible to the account.
OpenIn sheetbashsame section
Create an AMI from an instance
Create an image snapshot from an EC2 instance.
OpenIn sheetbashsame section
Delete a snapshot
Remove a no-longer-needed snapshot.
OpenIn sheetbash3 tag match
Describe instances
List EC2 instances and their attributes.
OpenIn sheetbash2 tag match