Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tbergeron/aws-snapanddelete-lambda
collection of scripts for cloud gaming on AWS in a cost-effective way
https://github.com/tbergeron/aws-snapanddelete-lambda
aws aws-lambda cloud-gaming lambda powershell
Last synced: 12 days ago
JSON representation
collection of scripts for cloud gaming on AWS in a cost-effective way
- Host: GitHub
- URL: https://github.com/tbergeron/aws-snapanddelete-lambda
- Owner: tbergeron
- Created: 2022-09-04T09:54:15.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-20T09:17:32.000Z (about 2 years ago)
- Last Synced: 2024-10-20T04:40:42.559Z (19 days ago)
- Topics: aws, aws-lambda, cloud-gaming, lambda, powershell
- Language: Python
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BEWARE!
- those scripts are provided AS-IS, if you are not well experienced with AWS **PLEASE DO NOT USE!**
- AWS bills can go crazy high FAST if you don't know what you're doing.
- if something wrong happens, i am **not** responsible and **i will provide no support**.# random bits of advice
- use `gp3` instead of `gp2` for volume types, it is most cost efficient / cheaper by about 30%
- as the following script implies, convert unused volumes to snapshots, and if you really don't use them often don't hesitate to archive the snapshots.
- snapshots are about half cheaper and archives are maybe 10 times even cheaper.
- as this script uses, `g4dn` are IMO the best instance type to use at the moment and it is good enough to run most AAA games.
- for huge games like Red Dead Redemption, a costly yet efficient way to speed up loading times and in-game texture streaming is to increase the volume `Throughput`.
- **BEWARE!** it cost a EXPONENTIALLY more than the defaults (default is 125MB/s)
- you can use the same `spawn-instance-from-image.py` script for spot instances. make sure you are allowed by AWS to use them first.# `snap-and-delete-on-stop.py`
- create a lambda function and copy/paste the code in it.
- make sure you set the timeout to some higher value ie. 15mins
- make sure you give the lambda permission:
- click on `Permissions` from the top, and click on the role that AWS automatically created for your function.
- click `Attach Policies`, search for EC2 and choose the `AmazonEC2FullAccess` policy. click `Attach Policy`
- using `EventBridge`, create a new rule with the following event pattern:```
{
"source": ["aws.ec2"],
"detail-type": ["EC2 Instance State-change Notification"],
"detail": {
"state": ["stopped"]
}
}
```- and use the lambda function you created as a target.
- that way, each time you stop an instance it will:
- delete old AMIs and their associated snapshots
- create a new AMI of the instance that got stopped
- terminate the instance
- delete all remaining volumes (**be careful, it will delete ALL volumes!!!**)# `spawn-instance-from-image.py`
- a script you can call using a bash or powershell script to redeploy the imaged instance
- follow the same lambda instructions as above (permissions, timeout, etc.)
- create a function URL (in the lambda configuration) that you can call via `curl`
- call that url whenever you need to spawn an instance of the last created AMI# `format-root-ebs.ps1`
- this script is meant to be ran ON the instance.
- CHANGE THE DRIVE LETTER based on your needs (hardcoded to `G`)
- script that can be executed on startup to format the ephemeral EBS root volume to NTFS.
- to execute on startup you can add a `cmd` script to the startup directory ie.
- in `C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp`
- create a `startFormatRootEBS.cmd` file and do something like:
```
PowerShell -Command "Set-ExecutionPolicy Unrestricted" >> "%TEMP%\StartupLog.txt" 2>&1
PowerShell %USERPROFILE%\Desktop\format-root-ebs.ps1 >> "%TEMP%\StartupLog.txt" 2>&1
```