- Terraform: Version 1.0.11 or later
- AWS CLI: Version 2.0 or later
- AWS Account: With appropriate permissions to create EC2 instances and security groups
- Infrastructure Provisioning: Use Terraform to provision the necessary AWS resources, including security groups and an EC2 instance.
- Configuration: A startup script (
minecraft.sh
) configures the EC2 instance, installs Java, downloads the Minecraft server, and sets up the server as a systemd service. - Deployment: Execute Terraform commands to initialize, format, validate, and apply the configuration, deploying the Minecraft server.
- Clone Repository: Clone this repository on to you local machine.
- Install Terraform: Follow the official guide to install Terraform.
- Install AWS CLI: Follow the official guide to install AWS CLI.
- Configure AWS CLI: Run
aws configure
and provide your AWS Access Key ID, Secret Access Key, region, and output format. a. You may need to enter a session token as well. To do this in your root directory typecd .aws
and then vim into the credentials file.vim credntials
and copy your aws_session_token below your key ID and access key. - Generate SSH Key: Generate an SSH key named
MinecraftKey
by going to the AWS dashboard, search for "key pairs" in the search bar, and click "Create key pair". Name itMinecraftKey
, and download the.pem
file into the cloned repository.
- Once you are ready run the start_server.sh script
./start_server.sh
- This script will run Terraform commands, which will apply the configuration, and execute the remote-exec provisioner. Once the script is done it will print the public IP address for the server. You can then connect using your
nmap -sV -Pn -p T:25565 <instance_public_ip>
and enjoy your server.
- Once you are done using the server run the command
terraform destroy
- Type yes to confirm the destruction of the server