Can not get Windows password of a new VM created from a custom AMI

amazon ec2

I have a Windows Server 2019 VM on AWS. I have created an AMI and launched an instance from that image.

I have picked the key pair which I use for the original VM.

After launch, when I select "Get Windows password", I see the following message:

Cannot retrieve Windows password
The Windows Password cannot be retrieved because this instance is not associated with a key pair. The administrator password may only be retrieved for instances that were associated with a key pair when launched.

I tried for a second time and I started another VM from the same image, this time I selected create new keypair. However I get the same message even with this one.

How can I create a windows AMI and get its password?

Best Answer

I suspect that this AMI was created without performing Sysprep [1] process, which it carries the credential configuration from the parent instance (instance from which the custom AMI was created).

In order to access the instance, I recommend using the administrator credentials of from parent instance in order to connect to it. As the credential configuration is carried over onto the AMI without Sysprep.

In order to resolve this issue, I suggest creating the AMI by performing the Sysprep [2] process. This process creates an AMI, which can be used as template to launch new instances without running through the same issue.