During my sophomore year of college, I created a Minecraft server hosted on AWS EC2 to reduce costs by only paying for server time when it was actively being used. I implemented an auto-shutdown feature and later integrated a Discord bot to allow friends to start the server directly from Discord. Using AWS Lambda, I optimized the system to start the server in under 30 seconds and added features such as server status updates, player count displays, and in-game chat integration with Discord. While the server was only used briefly, the project showcased the potential of combining AWS services with Discord for dynamic, cost-efficient server management.
During my sophomore year of college, a few friends and I decided to set up a Minecraft server. We were frustrated with existing Minecraft hosting sites, which charge by the month even when the server isn't being used. It felt wasteful paying for something that was active less than 10% of the time. I knew about AWS EC2 for hosting servers, so I started researching whether it was possible to host a Minecraft server on an EC2 instance. After some digging, I found instructions on how to do it. However, these instructions were tough to follow for a non-programmer like myself, as they were mostly written by parents or developers who were creating servers for their kids or for their own use. Even so, I managed to learn enough to create my own Minecraft server that I could start and stop at will, only paying for the time it was active.
I also implemented an auto-stop feature that would shut down the server after a set amount of time if no one was online. While this solved part of the issue, the one major drawback was that I was the only one who could start the server. Eventually, the project got sidelined as interest waned—until the summer when one of my friends reached out wanting to revive the server.
We set a start date, and this time, I decided to integrate Discord, so that anyone in our group could start the server directly from Discord. I initially thought the best way to accomplish this was by starting a smaller EC2 instance that would host a Discord bot, which could then start the larger EC2 instance running the Minecraft server. However, this conflicted with my goal of only running a server when it was actually needed. After more research, I discovered it was possible to host a Discord bot on AWS Lambda, which would only run when triggered. This, of course, came with its own challenges, particularly around getting Discord to authenticate the bot.
With the help of ChatGPT and a few online guides, I eventually created a Discord bot hosted entirely on AWS Lambda. The bot would start my EC2 instance, which would then automatically launch the Minecraft server. From the moment a user told the Discord bot to start the server, it took between 10 to 30 seconds for the Minecraft server to be fully operational. Initially, this took closer to a minute, but through some optimizations, I was able to cut the time in half.
While my friends were happy with this feature, I wasn’t satisfied yet. I wanted the bot to provide more functionality. I found a way to have the server communicate back to the Discord bot. Now, when the Minecraft server was ready, the bot’s status in Discord would change to "online," and when the server was down, it would revert to "offline." This made it incredibly easy for anyone to check the server's status at a glance. I also added a feature that showed how many players were currently online, as well as another feature that forwarded in-game chat messages to a specific Discord channel—and vice versa.
These features required a lot of trial and error due to Discord’s strict rules about what bots can and cannot do. I only managed to get everything fully functional for about a week before the server’s popularity began to decline, which was a bit disappointing. I was eager to see how my friends would use these new features. My next step is to explore using AWS CloudFormation to automatically set up the Minecraft server and its associated features, making it easier to deploy in the future.