Terraform infrastructure to deploy a Valheim dedicated server on AWS ECS Fargate with EFS persistent storage and S3 backups.
- ECS Fargate - Serverless container compute (2 vCPU, 4GB RAM)
- EFS - Persistent storage for world saves
- S3 - Backup storage with 30-day lifecycle
- CloudWatch - Container logs
- VPC - Isolated network with public IP
- AWS CLI configured (
aws configure) - Terraform >= 1.0
- AWS account with IAM permissions for ECS, EFS, S3, VPC
- Clone and initialize:
git clone <your-repo>
cd valheim-ecs
terraform init
- Configure (optional):
Edit
terraform.tfvars:
server_name = "4mp3d's Server"
world_name = "Dedicated"
password = "Eriksson"
aws_region = "us-east-1"
- Deploy:
terraform plan
terraform apply
- Get server IP:
aws ecs describe-tasks
--cluster valheim-cluster
--tasks $(aws ecs list-tasks --cluster valheim-cluster --query 'taskArns[0]' --output text)
--query 'tasks[0].attachments[0].details[?name==networkInterfaceId].value'
--output text | xargs aws ec2 describe-network-interfaces
--network-interface-ids | grep PublicIp
- Connect in Valheim:
- IP:
YOUR_IP:2456 - Password:
Eriksson
| Setting | Value | Description |
|---|---|---|
| Server Name | 4mp3d's Server |
Display name in server list |
| World | Dedicated |
World save name |
| Password | Eriksson |
Connection password |
| Save Interval | 30 min | Auto-save frequency |
| Backups | 3 rolling | Every 2 hours, kept 6 hours |
| Modifiers | Raids: Much Less | Reduced raid frequency |
~$50-60/month running 24/7:
- ECS Fargate (2 vCPU, 4GB): ~$45
- EFS (10GB): ~$3
- S3 backups: ~$0.50
- Data transfer: ~$5-10
View logs:
aws logs tail /ecs/valheim --follow
Stop server (keeps data):
aws ecs update-service --cluster valheim-cluster --service valheim-server --desired-count 0
Start server:
aws ecs update-service --cluster valheim-cluster --service valheim-server --desired-count 1
Download backup:
aws s3 sync s3://$(terraform output -raw backup_bucket)/backups/ ./local-backups/
terraform destroy
| Issue | Solution |
|---|---|
| "Wrong password" | Check SERVER_PASS env var in task definition |
| Container keeps stopping | Check CloudWatch logs: aws logs tail /ecs/valheim |
| Can't connect | Verify security group allows UDP 2456-2458 |
| No server in browser | Wait 2-3 minutes for Steam registration |
main.tf- Main infrastructure (VPC, ECS, EFS, S3)variables.tf- Input variablesterraform.tfvars- User configuration
- Docker image:
lloesche/valheim-server