aws-simple-ec2-cli icon indicating copy to clipboard operation
aws-simple-ec2-cli copied to clipboard

Auto-terminate doesn't work on Windows instances

Open snay2 opened this issue 2 years ago • 0 comments

Describe the bug simple-ec2 offers a feature to auto-terminate an instance you launch a certain number of minutes after its creation. This is nice for testing where you only need an instance for a short amount of time, since you don't have to worry about cleanup.

However, this mechanism only works on Linux instances, not Windows instances.

Steps to reproduce:

  1. Run simple-ec2 launch -i
  2. Use any values you like but specify the following:
    1. Windows AMI
    2. Auto-terminate timer of some short duration (e.g., 15 minutes)
  3. Launch the instance, wait a few minutes, and verify that the instance is running (it will show up in the AWS Console or in the list in simple-ec2 connect -i
  4. Wait 15 minutes

Result: The Windows instance is still running and it did not terminate

Expected outcome:

The Windows instance should terminate after the set time. If this is not possible, simple-ec2 should not give the user that option when selecting a Windows AMI.

This mechanism is implemented with a "shut down in the future" command in the userdata script, but that command is specific to Linux. It may be possible to do this in Windows with the following PowerShell command:

shutdown -s -t <TimeInSeconds>

Workaround:

Manually terminate the instance with simple-ec2 terminate or via the AWS Console

Environment

  • App Version: 0.6.0
  • OS/Arch: MacOS 12.2 Intel

snay2 avatar Mar 09 '22 15:03 snay2