Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samchungy/valheim-aws-spot-server
Launches a Valheim Server on an EC2 Spot Instance with a Discord Bot
https://github.com/samchungy/valheim-aws-spot-server
aws discord discord-bot ec2 github-actions instance serverless spot valheim
Last synced: about 1 month ago
JSON representation
Launches a Valheim Server on an EC2 Spot Instance with a Discord Bot
- Host: GitHub
- URL: https://github.com/samchungy/valheim-aws-spot-server
- Owner: samchungy
- Created: 2021-09-25T12:36:04.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-10-24T07:48:23.000Z (about 2 years ago)
- Last Synced: 2024-05-01T14:54:45.069Z (7 months ago)
- Topics: aws, discord, discord-bot, ec2, github-actions, instance, serverless, spot, valheim
- Language: TypeScript
- Homepage:
- Size: 228 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Valheim AWS Spot Instance Server
- Launches a Valheim Server on an EC2 Spot Instance which backs up to S3 all from GitHub Actions.
- Also creates a receiver for 2 slash commands on Discord - `/valheim start` and `/valheim stop` to start/stop the server.## Installation
1. Clone Repo and commit to a private repo on Github.
2. Adjust the config in Serverless.yml under Custom > Config. You will need to adjust
- `bucketName`
- `region`
- `serverName`
- `instanceType` (optional)3. Add the following secrets to GitHub Actions Secrets
```
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
DISCORD_PUBLIC_TOKEN
SERVER_PASSWORD # Valheim Server Password
SERVER_WEBHOOK # Discord Server Webhook URL
```4. Run the workflow. Profit.
5. You can remove the Elastic IP option if you want to save a bit more money. Just delete all configuration with `ElasticIP` in it from the `serverless.yml` file. It will spit out the designated IP on every start.
## Discord Slash Commands
You can setup Slash commands for your server here: https://discord.com/developers/docs/interactions/application-commands. Use the URL from the API Gateway path as the action endpoint for Discord. It will appear in the action's logs like this:```
endpoints:
POST - https://RANDOMID.execute-api.REGION.amazonaws.com/dev/interactions
```### Slash Command Discord API Sample Request Payload
```
{
"name": "valheim",
"description": "start or stop the valheim server",
"options": [
{
"name": "start",
"description": "Start the valheim server",
"type": 1
},
{
"name": "stop",
"description": "Stop the valheim server",
"type": 1
}
],
"default_permission": false
}
```If you don't wish to use the Discord Slash Command integration you can invoke the start/stop Lambdas using the AWS CLI. eg.
```
aws lambda invoke \
--function-name valheim-dev-start-server \
--invocation-type Event \
--payload '{}'
```