My 7 years old son is a fan of Minecraft. He started playing last year (2023) and he only talk about that the last 6 months. Now, he want to play with us, me, my wife, my 5 years old daughter, as well with some cousins.
It's available lots of servers on the internet, both paid or free, but those server don't have the security I want to my kid.
It's true that I'm a nerd father, so I had the idea of creating my own Minecraft Server on AWS. A server it will be used only by us.
So, if you want to learn a little about AWS in a fun way or you're a parent wanting to create a Minecraft server to your kids, here a GitHub repository that I created for that: https://github.com/epiresdasilva/aws-minecraft-server
To create this server, we'll use the following AWS services:
If you're not familiar with these services, I recommend to study the basics first, including Security Groups on EC2.
Steps
It's very simple to create a Minecraft server. To do this faster and reproduceble, I create a CloudFormation code for that.
In the repository, you'll find a file called minecraft-server.yaml
.
Basically, in this file I create a Security Group to allow only few ports I want to expose to the internet, like SSH and the port 25565 that is the port Minecraft Launcher connects.
MinecraftSecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupDescription: 'Enable SSH and Minecraft server port'
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 25565
ToPort: 25565
CidrIp: 0.0.0.0/0
Another important part is creating the EC2 instance. Basically, you need to choose the Linux image you want, as well the instance type. I choose a t4g.small
and it's running very well. I just need to understand if can be a smaller instance yet.
InstanceType: t4g.small
ImageId: ami-02cd6549baea35b55
KeyName: Minecraft Server
The instance type you can find in the EC2 page or using the AWS Calculator, so doing that it's easier to understand how much it will costs.
The image ID you'll find on the AMI Marketplace on the EC2 section on your AWS Management Console.
You need to create a KeyPair also on the EC2 section. After creating, just put the name in the "KeyName" on the YAML file.
Finally, you just need to run the following command:
aws cloudformation create-stack --stack-name MinecraftServerStack --template-body file://minecraft-server.yaml --region us-east-1
Security
Remember, DO NOT create that stack using your root user. Create an especific one to that. On doing that, remember to give only the necessary permissions you need. For instance, I used AmazonEC2FullAccess
and AWSCloudFormationFullAccess
and worked fine, but maybe can be more restricted yet.
This template doesn't create an advanced security for that server, so if you need to improve security it's important working on new layers of security in that template.
In my server, I made a configuration using Security Group to allow only connections from my IP, so I avoid other users to connect to my server even if they know my EC2 address.
Following it's how you can do that in the AWS Management Console:
Reboot
The script for running the Minecraft will run only for the first time when the EC2 instance is created. So, if your instance reboot the Minecraft Server won't start again.
After creating my EC2 instance, I create a systemd
to handle with that, but I didn't add that to my template.
- Create a systemd service file: ```bash
sudo vi /etc/systemd/system/minecraft.service
2. Create the content:
```ini
[Unit]
Description=Minecraft Server
After=network.target
[Service]
User=root
Nice=5
KillMode=none
SuccessExitStatus=0 1
InaccessibleDirectories=/root /sys /srv /media -/lost+found
NoNewPrivileges=true
WorkingDirectory=/
ExecStart=/opt/jdk-17.0.9/bin/java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui
ExecStop=/bin/kill -SIGINT $MAINPID
[Install]
WantedBy=multi-user.target
- Reload the systemd:
sudo systemctl daemon-reload
- Enable the service:
sudo systemctl enable minecraft.service
- Start the service:
sudo systemctl start minecraft.service
- Check the service status:
sudo systemctl status minecraft.service
- Service logs:
sudo journalctl -u minecraft.service
Playing Minecraft
Now, you have your own Minecraft Server and you are able to play with your friends and family.
Top comments (3)
I set one of these up a few years back for my kids but my setup was more of a hack. This looks much more clean. Thanks for sharing!
That’s awesome your whole family is getting into Minecraft together! Running a server on AWS is a cool project, but if you want an easier, family-friendly option, you might want to check out Minecraft. They’ve got reliable game server hosting that’s perfect for setting up your Minecraft world without all the technical hassle. It’s a great way to make sure everyone can join in on the fun—cousins and all!
Using a free Minecraft server can be a great alternative for those who want a simple and cost-effective way to host their worlds. It’s especially useful for small groups or testing out mods without the complexities of managing AWS. Plus, you can easily get started here: godlike.host/minecraft-free-server.... It’s an excellent solution for anyone looking to dive into multiplayer Minecraft with minimal hassle!