jabrythehutt / awsrd

Provision AWS EC2 instance for running VS Code remotely
MIT License
5 stars 0 forks source link

suspend/resume of EC2 instances #24

Open GitTom opened 1 year ago

GitTom commented 1 year ago

The README.md says

Create remote development EC2 instances that shut down automatically when inactive

But, AWS EC2 (and now GCP Compute Engine too) supports suspend/resume for its VM's. I think this is very useful - allowing VM to be resumed more quickly when I want to start working again, and without losing my state.

Is it be possible to support suspend/resume of VM's (as well as start up/shut down)? Does SSM even support suspend/resume?

The ideal would be resume my dev instance when automatically somehow. Not sure how. Perhaps when VSCode starts, eg. https://code.visualstudio.com/api/references/activation-events#onStartupFinished

Just some thoughts/feedback. Thanks.

jabrythehutt commented 1 year ago

Many thanks for your suggestion @GitTom

I've released a new version of the extension that hibernates/resumes supported EC2 instance types (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/hibernating-prerequisites.html).

I'll have to think about how to implement some sort of auto-resume functionality - would it be desirable for all auto-hibernated/stopped instances in a given region to spin up again when the explorer view is re-opened? This could get confusing when you're working with multiple projects and machines.

Perhaps auto-resuming instances would make more sense if an instance was linked to a repo somehow (like a Codespace) rather than just belonging to an account/region?

GitTom commented 1 year ago

Wow, that's great, thanks!

Yes, how to do the auto resume is tricky.

I agree that it is not ideal to resume all instances (in a region, or otherwise). I sit down to work and just need one instance - usually the last one I was working on. I guess the ideal would be for the extension to either allow me to mark which instances I want to auto resume, or have it do the last one I used.

GitTom commented 1 year ago

BTW, I just went to install the extension and it says

"The 'AWS Remote Development' extension is not available in Visual Studio Code for Windows 64 bit"

I must have missed that before. Whoops. So it is just for Linux and Mac?

jabrythehutt commented 1 year ago

Hey @GitTom this project builds and packages the session manager plugin (https://github.com/aws/session-manager-plugin) so that the user isn't required to install it manually (https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html). There are some extra steps required to getting a Windows version working and I didn't have time to commandeer a Windows machine for manual testing since I suspected that many developers would be using WSL (https://code.visualstudio.com/docs/remote/wsl).

I've opened #26 in case this is something that doesn't work well with WSL.

jabrythehutt commented 1 year ago

@GitTom WRT auto-resume, I was thinking that a clean approach to solving the problem would be something config-driven where a machine is launched/resumed based on the presence of a known file within a repo (like a devcontainer.json). The experience could then be similar to resuming a Codespace where the repo is automatically cloned and opened in a devcontainer once the connection is established.

GitTom commented 1 year ago

W/R to your plan for auto resume, what if someone works on a series over projects/repos, and each time they start working on a new one they make the configuration change so that the project gets auto-resumed. Do you anticipate that your extension would then auto-resume each of them unless the developer goes back and reverts the change in the repo's they aren't using?

Maybe you are addressing a different use case. Here's where I'm coming from ...

I would only want the repo I'm currently working on to auto resume - I think this would be the standard use case for a developer.

If I come back to my development work (after some period of doing other things) and I have to manually initiate the resumption of my EC2 instance, wait for it to resume, and then connect to it, then it doesn't feel very "available". It's a small thing, but it means that it doesn't feel like local development.

The codespaces feel pretty good because the only issue is waiting for a new instance to start up, but for various reasons I think most devs want to work mostly in a full VM and not a codespace.

Hope this helps. Thanks, Tom