Skip to content

haziqishere/minecraft_server_aws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

95 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ Kroni Survival Minecraft Server on AWS

Project Overview

Kroni Survival is a Minecraft server deployment solution that provides:

  • AWS Lightsail instance (4 vCPU, 4GB RAM) in Singapore region
  • Docker-based Minecraft server with cracked client support
  • Persistent storage for world data
  • Automated backups (S3 and Lightsail snapshots)
  • Monitoring via CloudWatch and Grafana
  • Discord notifications for server events

๐Ÿ“ Key Features

  • AWS Lightsail Instance with Docker
  • Minecraft Server (with cracked client support)
  • Persistent Storage with Lightsail Block Storage
  • Automated Backups:
    • Lightsail snapshots (biweekly)
    • S3 backups
  • Discord Notifications for backups and monitoring
  • Prefect Workflows for server monitoring and backup automation

๐Ÿ—๏ธ Architecture

Kroni Survival AWS Architecture

                   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                   โ”‚       You & Friends          โ”‚
                   โ”‚       (Singapore)            โ”‚
                   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                โ”‚
                                โ–ผ
                   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                   โ”‚     Lightsail Firewall       โ”‚
                   โ”‚   - Port 25565 (MC)          โ”‚
                   โ”‚   - Port 22 (optional SSH)   โ”‚
                   โ”‚   - Port 4200 (Prefect UI)   โ”‚
                   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                โ–ผ
                   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                   โ”‚  Lightsail Instance          โ”‚
                   โ”‚  - 2vCPU, 2GB RAM (small_3_0) โ”‚
                   โ”‚  - Docker                    โ”‚
                   โ”‚  - Minecraft Container       โ”‚
                   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                โ”‚
                                โ–ผ
                   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                   โ”‚  Lightsail Block Storage     โ”‚
                   โ”‚  - Mounted to /data          โ”‚
                   โ”‚  - World stored at /data/world โ”‚
                   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                โ–ผ
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚              Automation & Monitoring            โ”‚
       โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
       โ”‚ โ”‚ Prefect (DAG)  โ”‚ โ”‚ GitHub Actions (CI/CD)  โ”‚  โ”‚
       โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
       โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
       โ”‚ โ”‚ Cron Jobs (Snapshots + S3 backup scripts)  โ”‚  โ”‚
       โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
       โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
       โ”‚ โ”‚ CloudWatch Agent โ†’ Grafana Cloud Dashboard โ”‚  โ”‚
       โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ—๏ธ Prerequisites

  • Terraform (v1.0.0+)
  • AWS CLI configured with appropriate credentials
  • SSH key pair registered with AWS Lightsail
  • S3 bucket for Terraform state (optional but recommended)

prefect/ โ”‚ โ””โ”€โ”€ snapshot_flow.py # Prefect workflow for backups โ”œโ”€โ”€ .github/ โ”‚ โ””โ”€โ”€ workflows/ โ”‚ โ””โ”€โ”€ terraform.yml # GitHub Actions workflow โ”œโ”€โ”€ README.md # Project documentation โ””โ”€โ”€ .env.example # Example environment variables

  • Discord webhook URL (for notification)

Minecraft Server Monitoring

Prefect Monitoring System

This repository contains a Prefect-based monitoring system for Minecraft servers running on AWS EC2. The system:

  1. Checks if the Minecraft server is running
  2. Collects system metrics (CPU, memory, disk usage)
  3. Measures world size growth
  4. Sends notifications to Discord

For detailed setup and usage instructions, see prefect/README.md.

Quick Start

For a guided setup process, use the quick setup script:

cd prefect
./quick_setup.sh

Or for manual setup:

# Set up SSH authentication
cd prefect/bin
./setup_ec2_auth.sh <path_to_key.pem> <ec2_ip> ec2-user

# Deploy the monitoring flow
./deploy_monitoring.sh

Deployment Instructions

Initial Setup

  1. Clone this repository:

    git clone https://github.com/yourusername/minecraft-server-on-aws.git
    cd minecraft-server-on-aws
  2. Create a copy of .env.example as .env and fill in your settings:

    cp .env.example .env
    # Edit .env with your preferred text editor
  3. Initialize Terraform:

    cd terraform
    terraform init

Deployment

  1. Review the Terraform plan:

    terraform plan
  2. Apply the configuration:

    terraform apply
  3. Once deployed, Terraform will output the server IP address and other important information.

Accessing the Minecraft Server

Connect to the server using the IP address from the Terraform output and port 25565.

Backup and Restore

Two types of backups are configured:

  • S3 Backups: Daily tar-compressed world data
  • Lightsail Snapshots: Biweekly snapshots of both instance and data volume

Manual Backup

To manually trigger a backup:

ssh ec2-user@<server-ip>
sudo /opt/kroni-survival/scripts/backup-to-s3.sh

Restore from Backup

To restore from an S3 backup:

# Instructions for restoration will be added

Monitoring

๐Ÿ“Š Monitoring The system includes a Prefect dashboard for monitoring server status and scheduled tasks:

Prefect UI: Access at http://your-server-ip:4200 CloudWatch Metrics: View in AWS Console or Grafana dashboard Discord Notifications: Regular updates on server health and backups

Maintenance

Stopping the Server

ssh ec2-user@<server-ip>
sudo docker stop minecraft-server

Starting the Server

ssh ec2-user@<server-ip>
sudo docker start minecraft-server

Viewing Logs

ssh ec2-user@<server-ip>
sudo docker logs minecraft-server

Cost Estimates

  • AWS Lightsail micro_2_0: ~$5/month
  • Block Storage (20GB): ~$2/month
  • S3 Storage for backups: Varies based on world size
  • Data Transfer: Varies based on player count

๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgements

About

Survival minecraft that run on aws with high availability and robust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published