Ever wanted to run your own Minecraft server in the cloud? This guide will walk you through the process.
Key steps we’ll cover in this guide:
Choosing and creating a server in AWS
Installing the Minecraft server
Launching the server
To start, all we need is an AWS account. Best practice with AWS accounts suggests you should never use your root account (the account you originally sign up with) if you don’t need to. So we’ll briefly cover how to set up an admin user account using AWS Identity and Access Management (IAM) to achieve this separation and we’ll also create an “admins” group to simplify administration for any future admin users who might be added.
As the name suggests, AWS IAM is a tool that allows you to manage access to AWS services, including creating users and users groups so each user can only access the bare minimum they need to — this concept of least privilege is a security best practice in AWS that we’ll apply later on when setting up the server.
In IAM, navigate to the Users menu. Click “Add users” and follow the prompts to add a User name “admin”

After clicking Next, we’ll create a group for Administrators to be included which provides full access to the account via the AdministratorAccess policy.

We will not add any tags on the next page and proceed to review and click “Create user”

This will create the user and provide everything needed to log into the account — including a URL. The important thing to note is that to log in as the user you have created, you must know the AWS Account ID.
Now that we have logged in as the new IAM user we can move on to the next step of choosing and creating an instance.
The AWS service used for this step is Amazon EC2, or Amazon Elastic Compute Cloud, which provides a computer for you to use, called an Instance. Technically, the instances are virtual machines run by AWS on various different hardware and with many configuration options, each with its own price points. Generally, choosing the right EC2 instance is the hardest part, but also very easy to change — especially increasing or decreasing the specs.
In this case, since the Minecraft server can only run on one core and generally needs a lot of memory, we’ll use an on-demand, c6g.medium instance which has 1vCPU, 2GiB of memory and up to 10GiB network performance. So far this has been more than enough for 2–3 players, even while generating chunks. I’m yet to get the same performance from the general purpose instances available.
After deciding the instance type to use, we have to go ahead and create it. This is a simple process with the AWS user interface. We won’t cover it here, but this can also be done via the command line or a programming language.
This will be the first time considering the region you want to host. In the top right-hand corner of the AWS interface, there will is an option for the region which should be changed to the closest region available to you — in my case Asia Pacific (Sydney). This region is where the server physically resides and the closer to your users, the better to reduce latency.
After navigating to EC2, click Launch instances and select the Amazon Machine Image (AMI) “Amazon Linux 2 AMI (HVM), SSD Volume Type, 64-bit (Arm).” 64-bit Arm is required because it is the only one compatible with the c6g instance family.

Select the instance type c6g.medium. The default options for steps 3, 4 and 5 are correct. However, we will configure the security group — a firewall — in the sixth step to allow us to access the server to install the server and to allow our Minecraft client to log into the server.

We’ll create a new security group called “minecraft” with two open ports — one for SSH on port 22 to access and set up the server, and one on port 25565 for the Minecraft client. At this stage, we’ll only create a rule for our access (“My IP”) but we’ll open this up for more users later. After this select “Review and Launch” and review the details of the instance — we’ll get a warning that this instance isn’t eligible for the free tier, which is expected.

After selecting “Launch” again, we have to create a key pair to be able to SSH to the server. SSH is a protocol to connect and send commands to the server that will allow us to install the Minecraft server and get it started. The Launch Instances button becomes available after downloading the key pair.

The exact details of how to SSH to the instance vary based on your local machine operating system. AWS has a good guide available to help connect to an instance. The guide is available here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstances.html
In this case, we will ssh in using Windows with the following command:
ssh –i path\to\key\file.pem ec2-user@public-ip4-address-or-dns
Which will provide the following interface when successful:

Congratulations! You’ve launched and connected to an EC2 instance in AWS. Now we just have to download and install the Minecraft server, and we’re ready to play.
The steps to install and launch the server are much the same as any other install — download the file, put it somewhere permanent and run it. That’s all we’ll do here, just through the command line.
For the latest vanilla Minecraft server, we need a more up-to-date version of Java (Java Development Kit 16) than the one which comes with the EC2 instance, so we’ll install that too.
Fortunately, AWS has its own version of this called Amazon Corretto 16 available for install using yum — a Linux package management tool — with the following commands which import the Corretto public key, add the repository and then install Corretto from the new repository.
sudo rpm --import https://yum.corretto.aws/corretto.keysudo curl -L -o /etc/yum.repos.d/corretto.repo https://yum.corretto.aws/corretto.reposudo yum install -y java-16-amazon-corretto-devel
We’ll also create a dedicated user for the server on the instance
After the user is created, we’ll make directories and download the latest version of the Minecraft server into them, then provide access to the “minecraft” user.
sudo mkdir /opt/minecraft/sudo mkdir /opt/minecraft/server/cd /opt/minecraft/serverwget https://launcher.mojang.com/v1/objects/a16d67e5807f57fc4e550299cf20226194497dc2/server.jarsudo chown -R minecraft:minecraft /opt/minecraft/
The URL for the latest version of the server can be found on the official Minecraft server page by copying the link with the latest jar. Minecraft has now been downloaded on the machine and is almost ready to run.

A little trick with running the Minecraft server for the first time is that you have to run it once, edit a eula.txt file to agree with the license and then start it again before it will run. The next steps show how to do this using vim, an inbuilt Linux text editor.
We’ll swap to the user and move to the server directory.
sudo su minecraftcd /opt/minecraft/server/
Run the following command to start the server. If you are using a different version of Minecraft server, update the version numbering.
java -Xmx1024M -Xms1024 -jar minecraft_server.1.17.1.jar nogui
The command will error and say you need to agree to the eula. Do so by running the following command
vim eula.txt
Navigate to the “eula=false” statement, press i and edit it to say “eula=true”. Press escape and type :x to save and exit. Any Minecraft server specific settings can be modified in a similar way using vim in the server.properties file.
Start the server again using the same command as above. And voila, the Minecraft server is running and will be available to log in after world generation is complete. Log in using the same public IP address as above in the Minecraft desktop client.
You now have a fully functioning Minecraft server hosted in AWS. Unfortunately, this server is not easy to administer. It might be good enough if you just want to leave the server on 24/7 and are happy to pay for the unused time. To make this server more cost effective and easy to use, we could:
Automate the server starting when the EC2 instance launches by turning it into a service.
Add simple start and stop interfaces for users to switch the server on and off in your absence — maybe even automatically stop after a period of no activity.
Implement proper backups so user progress isn’t lost if something goes wrong.
A special thanks to this article by Julien Bras which taught me a lot about how to set up and host the server myself.
https://dev.to/julbrs/how-to-run-a-minecraft-server-on-aws-for-less-than-3-us-a-month-409p

