Terraform project for deploying a Terraria server running TShock on DigitalOcean
You should have:
- Terraform already set up (https://learn.hashicorp.com/terraform/getting-started/install.html)
- A DigitalOcean personal access token (https://www.digitalocean.com/docs/api/create-personal-access-token/)
- Create a new SSH key pair called
id_terraria
:ssh-keygen -f id_terraria -t ed25519 -N '' -C ''
- Run
terraform init
. - Copy
terraform.tfvars.template
toterraform.tfvars
:cp terraform.tfvars.template terraform.tfvars
. - Add your DigitalOcean personal access token to
terraform.tfvars
. - Run
terraform apply
. This will output the server's IP address when complete. - Monitor the server setup using
ssh -i id_terraria terraria@$(terraform output ip) tail -f /var/log/cloud-init-output.log
. The setup is complete once you see a line starting withCloud-init ... finished
. - At this point, TShock should have started and will take some time to create a new world.
- Launch Terraria and connect to the server at its IP address on port 7777.
To connect to the server, run ssh -i id_terraria terraria@$(terraform output ip)
from the project directory.
To interact with the TShock process, run screen -r tshock
on the server. You
can do this to see the auth code for becoming a super admin.
Hit Control + A and then D to detach from the screen without stopping the TShock process.