Skip to content

Latest commit

 

History

History
92 lines (72 loc) · 5.03 KB

README.md

File metadata and controls

92 lines (72 loc) · 5.03 KB

Valheim Server

This Terraform module will create a small Valheim server in AWS

Server is configured to load world backups from AWS S3 and send a new backup to S3 before shutdown.

THIS COSTS MONEY. Running a t3.medium costs roughly 30$ a month

Resources Created By This Terraform Module:

  • IAM role for s3 and AWS SSM sessions (AWS ssh equivalent)
  • Server (t3.medium)
  • Security Group to only allow UDP ingresss on ports 2456-2458

Prerequisites:

How to deploy

  • Prepare
    • Create a new S3 bucket in your account
      • create a folder in the bucket called latest
      • copy your valheim world data from your local computer to this folder in your s3 bucket (files will have a .db and .fwl extension)
    • Copy the example main.tf from main.tf and fill in any empty quotes ""
  • Build cloud resources
    • terraform init; terraform plan will show you what will be created
    • terraform init; terraform apply will deploy everything after typing yes
  • Connect to server (for debugging):
    • aws ssm start-session --target $(terraform output -json | jq -r '."instance-id".value') will start and AWS SSM session to log into the server.
      • you need to have the awscli installed as well as the aws ssm session plugin
      • Useful commands:
        • tail -f /var/log/cloud-init-output.log to debug the userdata.sh
        • systemctl status valheim to see the valheim service status
        • journalctl --unit valheim to see the valheim server logslogs

Requirements

No requirements.

Providers

Name Version
aws n/a
template n/a

Modules

No modules.

Resources

Name Type
aws_iam_instance_profile.session_manager resource
aws_iam_policy.session_manger resource
aws_iam_role.session_manager resource
aws_iam_role_policy_attachment.session_manager resource
aws_instance.main resource
aws_security_group.main resource
aws_security_group_rule.egress resource
aws_security_group_rule.ingress resource
aws_ami.amazon_linux_2 data source
template_file.userdata data source

Inputs

Name Description Type Default Required
instance_type This is the size of your server (t2.micro: 1 cpu, 2GB ram, this is free tier; t3a.medium, 2 cpu, 4GB ram, not sure why I used this) string "t2.micro" no
s3_bucket_name This is the s3 bucket you will be using to store your world files in. any n/a yes
server_name This doesn't matter much. If you're server is public, this will be shown in the list of community servers. string "MyServer" no
server_password This is the password users will enter after they put in the IP address of the server. any n/a yes
world_name world_name must be the same name as your world files (ex: world_name = "myworld" would correlate with myworld.db and myworld.fwl). any n/a yes

Outputs

Name Description
instance-id ======= outputs =======
public-ip n/a