Start / Stop AWS EC2 instances from your MacOS menu bar

xbar to the rescue!

I was looking for a convenient way to start or stop AWS EC2 instances, for example from the MacOS menu bar.
And the internet / GitHub did not let me down: xbar is the way to go!

GitHub – matryer/xbar: Put the output from any script or program into your macOS Menu Bar (the BitBar reboot)

Plugins

With xbar you can use many plugins; I am just using this one to start my EC2 instances:

xbar-plugins/ec2-start-stop.1h.sh at main ยท matryer/xbar-plugins

The installation notes are in that file as well:

# Installation:
# 1. Copy this script to your BitBar plugin folder
# 2. Ensure the plugin file is executable by running chmod +x ec2-start-stop.1h.sh
# 3. Change your AWS profile in the AWS_CLI_PROFILE variable below
# Notes: Optionally, to display the instace name in bitbar, use the key "Name" in AWS EC2 Tags

The plugin folder is ~/Library/Application Support/xbar/plugins

Dependencies

Be also aware of the Dependencies:
awscli (https://aws.amazon.com/cli/)
jq (https://stedolan.github.io/jq/)

That means you have to setup your awscli before e. g. the command aws ec2 describe-instances should output your current EC2 instances – then you are good to go to use the AWS profile within xbar. I created a new AWS profile just for EC2 management and added that to AWS CLI.

Conclusion

The setup was quite straightforward – and if you already have an AWS CLI profile setup it is even quicker. I like the fast and easy way to start my EC2 instances for demos. All my EC2 instances are ALWAYS stopped at 6PM every day with an AWS CloudFormation stack https://aws.amazon.com/premiumsupport/knowledge-center/stop-start-instance-scheduler/
NONE of my VMs are started automatically, I always do that via xbar (or the AWS mobile application) on demand – to save costs and also save resources. 🌱

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *