Minecraft on AWS with my daughter
“I can’t believe it actually works!”
“I can’t believe it actually works!” exclaimed my daughter. I could only empathise. I’d just shown her how to setup port-forwarding on our router, so that her friend could connect to the game of minecraft on our desktop.
“Wait. Does this mean that anyone can connect to my game?” she asked, pausing for a moment. “Do we have to use our computer?”
And just like that, in a day, we’d gone from knowing how to find your IP address for a LAN party, to punching a hole in our firewall for a remote client, to seriously considering hosting a minecraft server on Amazon Web Services.
At work, on the cloud-native fintech platform LUSID, this is our devops bread and butter. Our service runs on AWS, supported by a sophisticated devops toolchain .. and managed by a great group who know a good opportunity when they see one:
So, armed with a couple of pointers and a sense of naive optimism we set off. What is the gap between a set of blog posts and a running minecraft server in the cloud?
Friday
“You need a plan, or we’re just going to get lost” I’d said. “What’s the end goal?”
“A minecraft server like mccentral.org.”
“Ok, so … first of all maybe let’s work out how to create a server ..”
She appeared, bleary eyed, on Friday morning. “We were up late talking about the server” she said. “I’ve got a list of things we want to do.” It was a good list, but was light on early detail. I suggested that we start small, and work out how to use terraform. I pointed her at what seemed like a decent link from gruntwork. “See how far you get”.
She got a long way, but it struck me that as devs we underestimate the experience we bring to bear on problems every day. The tutorial starts by setting up an Amazon Web Services account, which was absolutely fine but requires a credit card so isn’t something a 12 year old can do on their own. Immediately, though, we were back to security and talking about Identity and Access Management (IAM) - and from there Lastpass for securely storing secret information, as during the process you create security keys that you must keep hold of.
Fortunately she’d used a Windows command prompt before but had never come across environment variables (“Dad - what’s a key-value pair?”); even so, with about an hour’s work she was set up, had terraform downloaded and was beginning to edit config files (“It’s like a recipe?”) before bed beckoned.
Saturday
“Can you hear me? Can you hear me now? Ah no – you need your sound turned up, hang on, where’s Discord …”
Thanks to lockdown, everyone in the family’s now familiar with Zoom. My daughter’s friend was interested in watching the process we went through. We’d set up a Zoom meeting because my daughter remembered she could share her screen; five minutes in and it was pretty much like 70% of other online meetings.
“So, I’m not a teacher, I don’t really know how to do this. Shall I just read the web page out, and you do what it says? I’ll try and fill in the gaps.”
I start reading the tutorial.
“This is like an IT lesson.”
“Well, you’re meant to be doing it, not me! Here, that’s next.”
“It’s terraform, init
!” they both called, delighted.
“I think something’s wrong!”
she said as the console window spewed beeps and junk text.
“Yep, good instincts.”
Stopping terraform in its tracks, I showed my daughter dir
to work out the file size. “See that 12000-ish number there? That means the file’s 12000 characters long”.
“I didn’t write 12000 letters”.
“Did you use Word for main.tf
? Word writes a whole load of extra junk. Let’s use notepad
and save it down again.”
“It says it’s worked; where is it?”
Once you’ve run terraform you (probably) have a server allocated to you and running … somewhere. Fortunately I could take them to the right view on the EC2 console having used it at work, and then explain how Amazon divided the world up into regions, and how to move between them, and how that related to the terraform configuration.
At this point they trusted that the row on the console meant that a server actually was running – or were too excited at the prospect of minecraft. Either way, we satisfied that we knew terraform inside out after writing a single main.tf
defining a region, a machine type, and an instance name, we moved on to Darrell Davies’ minecraft on AWS terraform module.
“There aren’t any actual instructions.”
No, that’s generally the case, I thought.
“Look, there’s a main.tf
file, just like the other example” I said. “I think we need to get a copy of this code, then run terraform init
and terraform apply
. Probably.”
I think this was where we had to make our first large leap. Copying Darrell’s repo is one thing - the kids were happy with zip files - but processing it with terraform implicitly assumed that you had a github account and had set up ssh keys. Even before that, you need to know that git is a thing and know how to navigate your way through the setup choices, including not choosing the default editor, vim.
They were familiar with the console now, moving between directories with cd
, knowing to wrap paths with spaces in quotes and even tab completing long filenames. A last terraform apply
and we were met with a screen of green text implying success, and telling us how to connect to our new server.
At this point I asked my daughter to ping
the public IP (“Does public mean that it’s got port forwarding on?”) with no success, some slightly exasperated noises and a realisation that ICMP traffic was probably blocked. “Imagine you had a thousand servers all pinging this one at the same time. It’d spend all its time answering them and not doing what it was meant to be doing.”
The deployment helpfully leaves you with the ssh
command to run as a sort of optimistic farewell. By this stage the kids had absorbed a lot of information. We ran it from git bash
. It worked.
We were connected. To an Ubuntu server.
“Ubuntu? What’s that?”
“At this point, it’s basically Windows.” I prevaricated. “It’s actually a version of Linux – that git bash
prompt you’ve been using behaves in a similar way. Here, take that public ip and this port, and see if you can both connect from minecraft.”
There followed a couple of hours spelunking around the terraform config and scripts in traditional dev style to work out where everything had been put, and what to run. As the kids wanted to be running version 1.14.4 rather than the latest we had to find the server jar - and I showed them curl
to download it directly with, and how to edit the startup script a bit.
We figured out that a backup of the game data was dropped into Amazon S3 so I showed them where it was, and we had some fun trying to work out how to edit the server’s server.properties
file to change the game mode, among other things.
Finally, as the kids wanted to use bukkit plugins, we worked out that we had to build a new version of the server jar ourselves - bukkit is a patched, decompiled minecraft server that can’t be published in a built state after being the target of a DMCA takedown. Fortunately the build instructions were straightforward, so with some new-found curl
skills we could get it built on the server directly, with enough time to play for a while before leaving the server until the following day.
Conclusion
Pretty much everything was covered by the pair of tutorials we were reading but, as is often the way, it’s the bits that aren’t covered that would have been an absolute timesink for someone who hadn’t been through these processes before.
You can tell from the number of links scattered throughout this blog that this process pulls together a lot of tools. Without someone with Windows and Linux console experience, and without experience of both git
and github – and specifically with setting up a public-private key pair to authenticate with – I think the process would have fallen apart pretty quickly.
It feels roughly analagous to the kind of thing you’d do in an old-style shop class: taking a car apart to get it working and put it back together again. We were lucky because we had time, but it’s definitely a multi-hour set of sessions even with a good clue.
That said, my daughter and her friend are 12. They pretty much sailed through it, we managed to get everything working, and they can now make the link between what they can do and what companies like Hypixel and mccentral actually do to make money.
I just need to keep an eye on my credit card bills for a month or so.