If you lose your private key, then you could be in a situation of never being able to access your EC2 instance again; however, this is dependent on what storage was selected for the root device of your EC2 instance. If your EC2 instance was EBS-backed and you lost your private key, then you can recover it. However, if it was an instance store-backed instance, then this is not possible.
To view the process of recovering this key, follow the steps detailed at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#replacing-lost-key-pair.
To determine whether your EC2 instance is EBS-backed or instance store-backed, follow these steps:
- Open the EC2 dashboard within the AWS Management Console.
- Select Instances and then select the instance you want to check.
- In the Details pane at the bottom of the screen, look for Root device type:
If the instance is EBS-backed, then the value will be ebs, as shown in the preceding screenshot...