If you are running Windows on EC2 using any of the M5, C5, R5, or T3 instance types, you may have noticed any of the following problems:
Windows does not shutdown gracefully when stopped using the AWS CLI or AWS Management Console
Windows does not reboot when rebooted using the AWS CLI or AWS Management Console
Creating an AMI image takes longer than usual, and signing-in to your EC2 instance afterwards show an "Unexpected Shutdown" prompt.
You may have seen that these problems do not occur on older EC2 instance types (M4, C4, R4, or T2).
β
These problems are new to the Nitro EC2 instances and come from how EC2 signals the Windows OS to initiate a shutdown or reboot. The Nitro EC2 instance types seem to do it differently compared to older instance types, and Windows does not respond properly.
AWS AMI images dated 2018-11-28 and later have been fixed.
To apply the fix on existing EC2 instances, please run the commands below in a CMD or PowerShell prompt on the instances to set the default Windows power management profiles to never turn off displays:
powercfg /setacvalueindex 381b4222-f694-41f0-9685-ff5bb260df2e 7516b95f-f776-4464-8c53-06167f40cc99 3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e 0
powercfg /setacvalueindex 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c 7516b95f-f776-4464-8c53-06167f40cc99 3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e 0
powercfg /setacvalueindex a1841308-3541-4fab-bc81-f71556f20b4a 7516b95f-f776-4464-8c53-06167f40cc99 3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e 0
The default included power management profiles are Balanced, High performance, and Power saver. If you have created and applied a custom profile, you can make the change using the below steps:
1. Run the following command to list existing power profiles. Retrieve the GUID for the active power scheme:
powercfg /l
2. Run the following command to set the power profile to never turn off displays, replacing POWER_SCHEME_GUID with the GUID retrieved in step 1:
powercfg /setacvalueindex POWER_SCHEME_GUID 7516b95f-f776-4464-8c53-06167f40cc99 3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e 0
You can apply these changes to multiple EC2 instances by utilizing Systems Manager Run Command with the AWS-RunPowerShellScript document:
βhttps://docs.aws.amazon.com/AWSEC2/latest/UserGuide/tutorial_run_command.html#rc-tutorial-ui
Additional References
β