On EC2 Windows Server 2016, automatically mount instance storage when restarting the instance

amazon ec2amazon-instance-storewindows-server-2016

I have an AWS EC2 instance based on an Amazon-provided AMI for Microsoft Windows Server 2016. I want to use the ephemeral Instance Storage. When I Start the instance, I can login and use the Window's Disk Management tool to mount my Instance Storage as a drive letter.

However, if I Stop and then Start the instance, the Instance Storage is no longer mounted when I login. I must again use the Window's Disk Management tool to remount the Instance Storage every time I restart the instance.

How can I make the Instance Storage appear as a drive automatically?

Best Answer

FYI here is a simpler solution based on the AWS EC2 docs

Run the following from a PowerShell window.

    #initial disk 1st time: 
    C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeDisks.ps1


    # schedule initial disk 
    C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeDisks.ps1 -Schedule