This tutorial walks through the process of automating the deployment of a Minecraft server using AWS, Terraform, Ansible, and Docker.
We'll use:
- Terraform to provision AWS infrastructure
- Ansible to configure the EC2 instance with Docker
- Docker Compose to run the Minecraft server container
- GitHub Actions to fully automate the pipeline on push
- AWS account with a valid IAM user or temporary credentials
- SSH key pair created in AWS EC2 console (e.g.,
Minecraft.pem) - Store AWS credentials and SSH private key in GitHub repo secrets:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_SESSION_TOKENKEY_PAIR_NAMESSH_PRIVATE_KEY = <your_private_key_contents>
For local runs:
export AWS_ACCESS_KEY_ID=<your_access_key_id>
export AWS_SECRET_ACCESS_KEY=<your_secret_access_key>
export AWS_SESSION_TOKEN <your_session_token>[GitHub Push] → [GitHub Actions Workflow]
↓
terraform init + apply
↓
[EC2 Instance w/ Public IP]
↓
ansible-playbook
↓
docker-compose up
↓
Minecraft Server @ port 25565
Start by cloning the repo:
git clone https://github.com/LeefiusBeefy/CS312-mc-server.git
cd CS312-mc-server
Update KEY_NAME in deploy.sh to your Key Pair name.
Then run deploy.sh using
./deploy.shStart by cloning the repo:
git clone https://github.com/LeefiusBeefy/CS312-mc-server.git
cd CS312-mc-server
On push to main, the workflow will:
- Run Terraform to provision EC2
- Configure it using Ansible
- Start the Minecraft container
Once deployed, connect using the public IP:
<instance_ip>:25565
You can verify it’s live with:
nmap -sV -Pn -p T:25565 <instance_ip>