This guide uses AWS leaner lab. Step and operations may differ if using other type of AWS accounts.
This guide expands on an earlier project, in which I set up a Minecraft server to run on an EC2 instance manually. This continuation uses Terraform and bash scripting to provision an AWS EC2 instance, Install if not already Java and a Minecraft server, then launch the service. The terracraft.sh file is the only script that needs to be run, making a simple and automated way to launch a Minecraft server.
- Valid AWS Credentials (Retrieve from AWS Academy Learner Lab module launch page)
- Terraform installed v1.12.1
- Follow Instructions at this link to install based on you OS Terraform install guide
- Must be able to change permissions and run .sh files from CLI
- nmap ( v7.95) installed on your local machine
- Clone this repo to a local directory
git clone git@github.com:TJForrest/Minecraft-p2.git - cd into the cloned directory Minecraft-p2
cd Minecraft-p2 - Make a file named creds to store your AWS credentials
vim creds - Generate a key pair. These will be stored in the keys directory
ssh-keygen -t rsa -b 4096 -f ./keys/minecraft-key - Navigate to the scripts directory
cd scripts - Make sure the script terracraft.sh has executable permissions
chmod +x terracraft.sh - Now run the script
./terracraft.sh - You will see a lot of output to the console as the script provisions using terraform, checks if the instance has java and Minecraft installed (installs if not), then finally runs an nmap to verify that the server is up and reachable.
- Once terracraft.sh has finished running copy the public IP address show in the output Line to find : The Minecraft server is not up and running at XXX.XXX.XXX.XXX:25565
- Open you Minecraft client and click multiplayer then Add Server
- Copy in the public IP to the Server Address bar and click done
- Once the Minecraft Client is done connecting you can click on the server and press launch.
- If using AWS learner lab you will need to update your creds file to fresh session credentials each time you have a new session.
- If there is any issues while terracraft.sh runs the script will stop and give you the error it came across.
- The script could have been designed to show less information when working through each step but I opted to leave it in so user can see what is going on.
