InvalidKeyPair.NotFound ☁️ AWS

InvalidKeyPair.NotFound: The key pair 'x' does not exist

The key pair name you passed doesn’t exist in that region (key pairs are regional).

Seen on: AWS

Meaning

Key pairs created in one region aren’t visible in others. Typos, deleted keys and Terraform configs that reference a key by name in another region cause it.

Common causes

  • Key pair created in a different region
  • Name typo or deleted key
  • Wrong account/profile

⚡ Quick fix

  1. List keys in the region: aws ec2 describe-key-pairs
  2. Import your public key into this region
  3. Use the right profile/region

Detailed fix by platform

AWS CLI

  1. bash
    aws ec2 describe-key-pairs --region eu-west-1 --query 'KeyPairs[].KeyName'
    aws ec2 import-key-pair --key-name deploy --public-key-material fileb://~/.ssh/id_ed25519.pub --region eu-west-1

How to diagnose

  1. Region — Where was the key created?
  2. Name — Exact key name

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.