This repository contains a playbook designed to deploy a Vanilla Minecraft server to AWS GameLift using Ansible Automation Platform (AAP / AWX).
The primary goal is to fully automate all AWS-side operations (IAM, S3, GameLift Fleet, Autoscaling).
This guide covers two parts:
- Manual Setup: How to configure AAP/AWX to run this playbook.
- Automated Deployment: How to set up a GitHub Actions workflow to automatically run the playbook on a
git push.
This playbook essentially does the following:
- Creates the necessary IAM roles and policies for GameLift on AWS.
- Creates an S3 bucket and uploads the Minecraft server build to it.
- Adds the build record to GameLift and creates a Fleet.
- Finally, it configures the Autoscaling policies.
So, we are turning "a job you would do with 20 commands locally" into a single Job Template in AAP.
To run this setup, you need the following:
- AWS account (GameLift must be enabled)
- IAM user/role (required permissions:
gamelift:*,iam:*,ec2:*,s3:*,autoscaling:*) - AAP (Ansible Automation Platform) or an open-source AWX installation
- A credential tested with AWS CLI (we will add this to AAP)
Before you can automate the trigger, you must first set up the project and template in AAP/AWX.
Create a Project in AWX / AAP:
- Type: Git
- SCM URL: The URL of this repository
- Branch: main (or your branch)
AAP needs credentials to talk to AWS.
In the AAP Dashboard: Credentials → Add → Amazon Web Services
- Name:
My AWS Credentials(or similar) - Access Key ID: (Your AWS Key)
- Secret Access Key: (Your AWS Secret)
- Default region: (e.g.,
eu-central-1)
Note: These AWS credentials stay inside AAP. They are never exposed to GitHub.
This template connects the Project (playbook), Inventory (where to run), and Credentials (how to authenticate).
Add a new Job Template in AAP:
| Field | Value |
|---|---|
| Name | Minecraft AWS GameLift Deploy |
| Inventory | localhost (You may need to create a simple "localhost" inventory) |
| Project | minecraft-gamelift (The project from Step 1) |
| Playbook | main.yaml |
| Credentials | My AWS Credentials (The AWS credential from Step 2) |
At this point, you can manually run this Job Template from the AAP dashboard to deploy your server. The next section explains how to automate this part.
This section explains how to automatically trigger the Job Template you just created every time you push code to your main branch (GitOps approach).
GitHub Actions needs a token to authenticate with the AAP/AWX API.
- In your AAP/AWX dashboard, go to Access → Users.
- Select the user you want to generate a token for (a dedicated "service account" user is recommended).
- Click the Tokens tab and Add.
- Type:
Personal Access Token - Scope:
Write(This allows the token to launch jobs). - Save and copy the token immediately. You will not see it again.
GitHub Actions needs to know which template to launch.
- In AAP/AWX, go to Resources → Templates.
- Click on your "Minecraft AWS GameLift Deploy" template.
- Look at the URL in your browser. It will look like this:
https://your-aap-host.com/#/templates/job_template/12 - The number at the end (e.g.,
12) is your Job Template ID. Note it down.
Add the AAP token and host information to your GitHub repository's secrets.
-
Go to your GitHub repository.
-
Go to Settings → Secrets and variables → Actions.
-
Click New repository secret and add the following three secrets:
- Name:
AWX_HOST- Value: Your full AAP/AWX server address (e.g.,
https://aap.mycompany.com)
- Value: Your full AAP/AWX server address (e.g.,
- Name:
AWX_API_TOKEN- Value: The API token you copied in Step 1.
- Name:
AWX_JOB_TEMPLATE_ID- Value: The Job Template ID you found in Step 2 (e.g.,
12).
- Value: The Job Template ID you found in Step 2 (e.g.,
- Name:
Create a file in your repository at this exact path: .github/workflows/deploy_minecraft.yml.
Copy and paste the following content into that file:
name: 🚀 Auto-Deploy Minecraft Server
on:
push:
branches:
- main
jobs:
deploy-to-awx:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create or Update AWX Project
run: |
echo "🔧 Checking or creating AWX Project..."
curl -s -X POST "${{ secrets.AWX_URL }}/api/v2/projects/" \
-H "Content-Type: application/json" \
-u "${{ secrets.AWX_USER }}:${{ secrets.AWX_PASS }}" \
-d '{
"name": "Minecraft_Deploy_Project",
"scm_type": "git",
"scm_url": "https://github.com/0gulcandogann/deploy_game_server_for_aws.git",
"scm_branch": "main",
"scm_update_on_launch": true
}' || echo "Project already exists or updated."
- name: Create or Update AWX Inventory
run: |
echo "📦 Checking or creating AWX Inventory..."
curl -s -X POST "${{ secrets.AWX_URL }}/api/v2/inventories/" \
-H "Content-Type: application/json" \
-u "${{ secrets.AWX_USER }}:${{ secrets.AWX_PASS }}" \
-d '{
"name": "Minecraft_Inventory",
"organization": 1
}' || echo "Inventory already exists or updated."
- name: Create AWX Credential (AWS)
run: |
echo "🔑 Creating AWX AWS credential..."
curl -s -X POST "${{ secrets.AWX_URL }}/api/v2/credentials/" \
-H "Content-Type: application/json" \
-u "${{ secrets.AWX_USER }}:${{ secrets.AWX_PASS }}" \
-d '{
"name": "AWS_Credentials",
"credential_type": 8,
"organization": 1,
"inputs": {
"username": "${{ secrets.AWS_ACCESS_KEY_ID }}",
"password": "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
}
}' || echo "Credential already exists or updated."
- name: Create or Update AWX Job Template
run: |
echo "🧱 Creating or updating AWX Job Template..."
curl -s -X POST "${{ secrets.AWX_URL }}/api/v2/job_templates/" \
-H "Content-Type: application/json" \
-u "${{ secrets.AWX_USER }}:${{ secrets.AWX_PASS }}" \
-d '{
"name": "Deploy_Minecraft_Server",
"job_type": "run",
"inventory": 1,
"project": 1,
"playbook": "deploy_minecraft.yml",
"credential": 1,
"become_enabled": true
}' || echo "Template already exists or updated."
- name: Launch AWX Job Template
run: |
echo "🚀 Launching AWX Job Template..."
curl -s -X POST "${{ secrets.AWX_URL }}/api/v2/job_templates/1/launch/" \
-u "${{ secrets.AWX_USER }}:${{ secrets.AWX_PASS }}"
Commit and push the new .github/workflows/deploy_minecraft.yml file to your main branch.
That's it! As soon as you push, you can go to the Actions tab in your GitHub repository. You will see the "Deploy Minecraft to AWS GameLift" workflow start. This workflow will securely connect to your AAP/AWX instance and launch the job, which in turn deploys your server to AWS.
To avoid AWS costs:
- If a
destroy.yamlplaybook exists, create a new Job Template for it and run it. - If not, manually clean up the created resources (Fleet, Build, IAM, S3) from the AWS Console.
- Currently configured for a Vanilla Minecraft server.
- You can add Paper, Spigot, or Fabric builds by modifying the
core.roles.buildsection in this repository. - If you want more advanced integration, this setup can easily be converted into an Ansible Operator.