Nice! I have a similar set of scripts for google cloud instances. And my favorite is also the resizing one. Just soo much more convenient than using the UI.
They also automatically mount an sshfs of the instance's home directory, which I found very helpful for e.g. working with output the instance produced that can't easily be interacted with in a terminal.
In case anyone is interested: gcloud-connect-instance, gcloud-change-type (but fair warning: I haven't used them in a while, and updates to the gcloud cli/api might have broken some things).
I do a lot of work on ec2 instances, and one thing that makes this easier is having a few scripts for manipulating them. These are very small, small enough to go in my
.bashrc
, but still make my life a lot easier.The first one is
start_ec2
:I have an instance I do most of my work on, and this command starts it. Way better than logging into the AWS Console like I used to do.
After a few seconds I run:
This figures out the IP of the instance, copies down my (very important) full shell history, and logs me in over ssh.
I don't have a command for shutting down remotely: I just run
sudo shutdown -h now
while logged in.The last command, and probably my favorite, is
resize_ec2
:For example,
resize_ec2 c6a.xlarge
orresize_ec2 c6a.32xlarge
. Depending on what I'm doing I might need very different specs, and I don't want to pay $4.90/hr when I only need a $0.15/hr machine. It does take a mildly annoying few minutes for a machine that has just shut down to transition into a state where you can resize it, but it's not too bad.