https://github.com/harry-moore-dev/terraform-aws-minecraft-server-module
Terraform module to deploy a Minecraft server to AWS
https://github.com/harry-moore-dev/terraform-aws-minecraft-server-module
aws minecraft minecraft-server terraform-module
Last synced: about 2 months ago
JSON representation
Terraform module to deploy a Minecraft server to AWS
- Host: GitHub
- URL: https://github.com/harry-moore-dev/terraform-aws-minecraft-server-module
- Owner: Harry-Moore-dev
- License: mit
- Created: 2024-02-10T22:07:27.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-13T21:21:38.000Z (about 2 years ago)
- Last Synced: 2025-05-16T20:11:06.431Z (about 1 year ago)
- Topics: aws, minecraft, minecraft-server, terraform-module
- Language: HCL
- Homepage: https://registry.terraform.io/modules/Harry-Moore-dev/minecraft-server-module/aws/latest
- Size: 56.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# terraform-aws-minecraft-server-module
Terraform module to deploy a Minecraft server to AWS. This module is designed to be stateless and ephemeral, creating and destroying a new server should be possible without affecting the saved Minecraft worlds, this is acheived by storing the saved data in s3 externally to this module on a destroy event.
# Usage
Simple example:
```hcl
module "beamMP_server" {
source = "Harry-Moore-dev/minecraft-server-module/aws"
version = "1.0.0"
s3_save_bucket_name = "some-save-bucket"
}
```
Detailed example:
```hcl
module "beamMP_server" {
source = "Harry-Moore-dev/minecraft-server-module/aws"
version = "1.0.0"
s3_save_bucket_name = "some-save-bucket"
region = "eu-west-1"
ec2_instance_type = "t3.large"
ec2_ebs_volume_size = 8
ec2_spot_instance_price = "0.01"
ec2_spot_instance_enabled = true
server_port = 25565
}
```
### Loading save data
This project creates an S3 bucket in your AWS account and load the save data to a path of your choice. All save files in that path will be copied over to the server on creation so sufficient ebs volume size should be specified depending on the size of the saves loaded. On instance termination (if running) the current world will be saved to the s3 bucket for future use.
## Pre-commit config
Install dependencies for pre-commit.
```
brew install pre-commit terraform-docs tflint tfsec
```
## Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 1.5.7 |
| [aws](#requirement\_aws) | 5.36.0 |
| [null](#requirement\_null) | >= 3.2.2 |
## Providers
| Name | Version |
|------|---------|
| [aws](#provider\_aws) | 5.36.0 |
| [null](#provider\_null) | 3.2.2 |
## Modules
| Name | Source | Version |
|------|--------|---------|
| [ec2](#module\_ec2) | terraform-aws-modules/ec2-instance/aws | 5.6.0 |
| [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | 5.1.0 |
## Resources
| Name | Type |
|------|------|
| [aws_default_vpc.default](https://registry.terraform.io/providers/hashicorp/aws/5.36.0/docs/resources/default_vpc) | resource |
| [aws_iam_instance_profile.ssm_instance_profile](https://registry.terraform.io/providers/hashicorp/aws/5.36.0/docs/resources/iam_instance_profile) | resource |
| [aws_iam_policy.s3_write_policy](https://registry.terraform.io/providers/hashicorp/aws/5.36.0/docs/resources/iam_policy) | resource |
| [aws_iam_role.ssm_role](https://registry.terraform.io/providers/hashicorp/aws/5.36.0/docs/resources/iam_role) | resource |
| [aws_iam_role_policy_attachment.s3_write_policy_attachment](https://registry.terraform.io/providers/hashicorp/aws/5.36.0/docs/resources/iam_role_policy_attachment) | resource |
| [aws_iam_role_policy_attachment.ssm_policy_attachment](https://registry.terraform.io/providers/hashicorp/aws/5.36.0/docs/resources/iam_role_policy_attachment) | resource |
| [aws_subnet.public_subnet](https://registry.terraform.io/providers/hashicorp/aws/5.36.0/docs/resources/subnet) | resource |
| [null_resource.create_s3_bucket_if_doesnt_exist](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/5.36.0/docs/data-sources/availability_zones) | data source |
| [aws_ssm_parameter.latest_ami](https://registry.terraform.io/providers/hashicorp/aws/5.36.0/docs/data-sources/ssm_parameter) | data source |
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [ec2\_architecture](#input\_ec2\_architecture) | ec2 instance architecture | `string` | `"x86_64"` | no |
| [ec2\_ebs\_volume\_size](#input\_ec2\_ebs\_volume\_size) | ec2 ebs volume size | `number` | `15` | no |
| [ec2\_instance\_type](#input\_ec2\_instance\_type) | ec2 instance type | `string` | `"t3.large"` | no |
| [ec2\_spot\_instance\_enabled](#input\_ec2\_spot\_instance\_enabled) | use ec2 spot instances (cheaper but can be terminated at any time) | `bool` | `false` | no |
| [ec2\_spot\_instance\_price](#input\_ec2\_spot\_instance\_price) | ec2 spot instance price (adjust this for the instance type if using spot instances) | `string` | `"0.01"` | no |
| [mc\_admins](#input\_mc\_admins) | A map of admins where the key is the UUID and the value is the username |
list(object({
uuid = string
name = string
level = number
bypassesPlayerLimit = bool
})) | `[]` | no |
| [mc\_allocated\_memory](#input\_mc\_allocated\_memory) | The amount of memory allocated to the Minecraft server java runtime in MB | `number` | `1024` | no |
| [mc\_allow\_flight](#input\_mc\_allow\_flight) | Whether flight is allowed on the Minecraft server | `bool` | `false` | no |
| [mc\_allow\_nether](#input\_mc\_allow\_nether) | Whether the nether is allowed on the Minecraft server | `bool` | `true` | no |
| [mc\_custom\_seed](#input\_mc\_custom\_seed) | Specify a custom seed for the Minecraft server (a random seed will be used if not specified) | `string` | `""` | no |
| [mc\_difficulty](#input\_mc\_difficulty) | The difficulty for the Minecraft server | `string` | `"easy"` | no |
| [mc\_enable\_command\_block](#input\_mc\_enable\_command\_block) | Whether command blocks are enabled on the server | `bool` | `false` | no |
| [mc\_force\_gamemode](#input\_mc\_force\_gamemode) | Whether to force the game mode on the Minecraft server | `bool` | `false` | no |
| [mc\_game\_mode](#input\_mc\_game\_mode) | The game mode for the Minecraft server | `string` | `"survival"` | no |
| [mc\_generate\_structures](#input\_mc\_generate\_structures) | Whether structures are generated in the Minecraft server | `bool` | `true` | no |
| [mc\_hardcore](#input\_mc\_hardcore) | Whether hardcore mode is enabled on the Minecraft server | `bool` | `false` | no |
| [mc\_level\_name](#input\_mc\_level\_name) | The name of the level for the Minecraft server | `string` | `"world"` | no |
| [mc\_level\_type](#input\_mc\_level\_type) | The type of level for the Minecraft server (: character must be double escaped with a backslash) | `string` | `"minecraft\\:normal"` | no |
| [mc\_max\_players](#input\_mc\_max\_players) | The maximum number of players for the Minecraft server | `number` | `20` | no |
| [mc\_max\_world\_size](#input\_mc\_max\_world\_size) | The maximum world size for the Minecraft server | `number` | `29999984` | no |
| [mc\_name](#input\_mc\_name) | The name of the Minecraft server | `string` | `"Minecraft Server"` | no |
| [mc\_player\_idle\_timeout](#input\_mc\_player\_idle\_timeout) | The idle timeout for the Minecraft server (0 to disable) | `number` | `0` | no |
| [mc\_pvp](#input\_mc\_pvp) | Whether PVP is enabled on the server | `bool` | `true` | no |
| [mc\_resource\_pack](#input\_mc\_resource\_pack) | The resource pack for the Minecraft server | `string` | `""` | no |
| [mc\_simulation\_distance](#input\_mc\_simulation\_distance) | The simulation distance for the Minecraft server | `number` | `12` | no |
| [mc\_spawn\_animals](#input\_mc\_spawn\_animals) | Whether animals spawn on the Minecraft server | `bool` | `true` | no |
| [mc\_spawn\_monsters](#input\_mc\_spawn\_monsters) | Whether monsters spawn on the Minecraft server | `bool` | `true` | no |
| [mc\_spawn\_npcs](#input\_mc\_spawn\_npcs) | Whether NPCs spawn on the Minecraft server | `bool` | `true` | no |
| [mc\_view\_distance](#input\_mc\_view\_distance) | The view distance for the Minecraft server | `number` | `32` | no |
| [mc\_whitelist\_enabled](#input\_mc\_whitelist\_enabled) | Whether the whitelist is enabled on the Minecraft server | `bool` | `false` | no |
| [mc\_whitelisted\_users](#input\_mc\_whitelisted\_users) | A map of whitelisted users where the key is the UUID and the value is the username | list(object({
uuid = string
name = string
})) | `[]` | no |
| [minecraft\_version](#input\_minecraft\_version) | The version of Minecraft Java edition to install, if not specified the latest version will be installed | `string` | `""` | no |
| [notification\_webhook\_url](#input\_notification\_webhook\_url) | The URL of the Discord webhook to send notifications to | `string` | `"https://webhook.site/87aba66d-bdaa-4337-85cf-7ef180f24146"` | no |
| [region](#input\_region) | AWS region | `string` | `"eu-west-2"` | no |
| [s3\_save\_bucket\_name](#input\_s3\_save\_bucket\_name) | The S3 bucket name to save the Minecraft server data | `string` | n/a | yes |
| [s3\_save\_bucket\_versioning](#input\_s3\_save\_bucket\_versioning) | Whether to enable versioning on the S3 bucket on first creation | `string` | `"Enabled"` | no |
| [server\_port](#input\_server\_port) | The port the server will run on | `number` | `25565` | no |
| [vpc\_subnet\_cidr\_block](#input\_vpc\_subnet\_cidr\_block) | value of the vpc cidr block for the public subnet | `string` | `"172.31.0.0/16"` | no |
## Outputs
| Name | Description |
|------|-------------|
| [server\_ip](#output\_server\_ip) | public IP of the EC2 instance used for direct connect |