AWS EC2 - Attach Key pair to existing instance


I have created a new EC2 without attaching key pair hence could not be able login. So plan to update the key pair alone but went wrong due to my approach as I just updated key_name parameter in the same TF template( that had destroyed the existing EC2 and created new EC2 with key-pair.

But the requirement was just updated key pair not entire ec2. Please help me out on the steps.

Thanks in advance.
Kiran Teki.