Motivation
Every year, the itch to play Minecraft with friends returns — but hosting a Java server efficiently (and affordably) is trickier than it should be. In my opinion, Java is far superior to Bedrock, but hosting it yourself can be a pain. And I’m not the type to pay a server company to do it for me.
While learning AWS, I explored how to host a Minecraft Java server using EC2. That part was fairly straightforward.
But the real issue came later — forgetting to shut it down.
One weekend, we accidentally left the server running after a session… and ended up with a surprise AWS bill.
To fix this, I started researching how to automate EC2 instance control — and stumbled on a fantastic blog post by Andrew Berry:
🔗 Andrew Berry’s EC2 Discord Bot Guide
That got me most of the way there. But once the automation itch began, it didn’t stop. Soon, we wanted to host more games too. That’s when I discovered Pterodactyl — an open-source game server management panel.
Using Google Cloud’s free tier, I set up Pterodactyl and integrated it with the EC2 instance. From there, I built a custom Discord bot to manage both EC2 and Pterodactyl via their APIs.
It’s still a work in progress, but it already does everything we need.
Server Management
The Discord bot can:
- Start and stop the EC2 instance
- Check its current state
- Display server uptime
- Notify if the server runs longer than a defined threshold
- Retrieve the current public IP (useful since we don’t use Elastic IPs)
This means no more forgotten instances eating up money—and a lot more peace of mind.
Discord Bot Commands
The bot supports the following commands:
/start → Starts the EC2 instance
/stop → Stops the EC2 instance
/state → Returns the current status of the instance
/uptime → Shows how long the instance has been running
/ip → Retrieves the current public IP
/ping → Checks if the server is reachable
Pterodactyl Integration
Through the Pterodactyl API, the bot can:
- List all game servers hosted on the panel
- Check the state of each game server
- Easily switch between game environments (e.g., Minecraft, Valheim)
This setup gives us a full game server management suite—all accessible through Discord.
🎮 Have questions or want to contribute?
Check out the code on GitHub and drop a star if you find it useful!
Notes from the Author
I built all this just to play Minecraft with friends, I regret nothing.