I'm trying to set up my infrastructure using Terraform and I need to access my EC2 private key to add it to my GitHub Action secrets. I missed the chance to download it during creation, so how can I retrieve or generate it safely?
1 Answer
You can only download the private key when you first create it. If you didn’t do that, unfortunately, you can't recover it and the EC2 key pair is useless now. However, you can generate a new key using Terraform and save the private key securely in a location like AWS Secrets Manager or SSM Parameter Store to avoid losing it in the future.
Thanks for the info! I will give that a try while using Terraform to automate my EC2 setup.