{"id":17447455,"url":"https://github.com/tbergeron/aws-snapanddelete-lambda","last_synced_at":"2026-04-14T23:33:34.268Z","repository":{"id":58566294,"uuid":"532499212","full_name":"tbergeron/AWS-SnapAndDelete-Lambda","owner":"tbergeron","description":"collection of scripts for cloud gaming on AWS in a cost-effective way","archived":false,"fork":false,"pushed_at":"2022-09-20T09:17:32.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-22T11:24:40.079Z","etag":null,"topics":["aws","aws-lambda","cloud-gaming","lambda","powershell"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tbergeron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-04T09:54:15.000Z","updated_at":"2022-11-17T13:55:34.000Z","dependencies_parsed_at":"2023-01-18T16:02:28.427Z","dependency_job_id":null,"html_url":"https://github.com/tbergeron/AWS-SnapAndDelete-Lambda","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tbergeron/AWS-SnapAndDelete-Lambda","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbergeron%2FAWS-SnapAndDelete-Lambda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbergeron%2FAWS-SnapAndDelete-Lambda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbergeron%2FAWS-SnapAndDelete-Lambda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbergeron%2FAWS-SnapAndDelete-Lambda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tbergeron","download_url":"https://codeload.github.com/tbergeron/AWS-SnapAndDelete-Lambda/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbergeron%2FAWS-SnapAndDelete-Lambda/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31819810,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"ssl_error","status_checked_at":"2026-04-14T18:05:01.765Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-lambda","cloud-gaming","lambda","powershell"],"created_at":"2024-10-17T19:39:31.059Z","updated_at":"2026-04-14T23:33:34.243Z","avatar_url":"https://github.com/tbergeron.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BEWARE!\n- those scripts are provided AS-IS, if you are not well experienced with AWS **PLEASE DO NOT USE!**\n  - AWS bills can go crazy high FAST if you don't know what you're doing.\n  - if something wrong happens, i am **not** responsible and **i will provide no support**.\n\n# random bits of advice\n- use `gp3` instead of `gp2` for volume types, it is most cost efficient / cheaper by about 30%\n- 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.\n  - snapshots are about half cheaper and archives are maybe 10 times even cheaper.\n- 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.\n- 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`.\n  - **BEWARE!** it cost a EXPONENTIALLY more than the defaults (default is 125MB/s) \n- 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.\n\n# `snap-and-delete-on-stop.py`\n- create a lambda function and copy/paste the code in it.\n- make sure you set the timeout to some higher value ie. 15mins\n- make sure you give the lambda permission:\n  - click on `Permissions` from the top, and click on the role that AWS automatically created for your function.\n  - click `Attach Policies`, search for EC2 and choose the `AmazonEC2FullAccess` policy. click `Attach Policy`\n- using `EventBridge`, create a new rule with the following event pattern:\n\n```\n{\n  \"source\": [\"aws.ec2\"],\n  \"detail-type\": [\"EC2 Instance State-change Notification\"],\n  \"detail\": {\n    \"state\": [\"stopped\"]\n  }\n}\n```\n\n- and use the lambda function you created as a target.\n- that way, each time you stop an instance it will:\n  - delete old AMIs and their associated snapshots\n  - create a new AMI of the instance that got stopped\n  - terminate the instance\n  - delete all remaining volumes (**be careful, it will delete ALL volumes!!!**)\n\n# `spawn-instance-from-image.py`\n- a script you can call using a bash or powershell script to redeploy the imaged instance\n- follow the same lambda instructions as above (permissions, timeout, etc.)\n- create a function URL (in the lambda configuration) that you can call via `curl`\n- call that url whenever you need to spawn an instance of the last created AMI\n\n# `format-root-ebs.ps1`\n- this script is meant to be ran ON the instance.\n- CHANGE THE DRIVE LETTER based on your needs (hardcoded to `G`)\n- script that can be executed on startup to format the ephemeral EBS root volume to NTFS.\n- to execute on startup you can add a `cmd` script to the startup directory ie.\n  - in `C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp`\n  - create a `startFormatRootEBS.cmd` file and do something like:\n```\nPowerShell -Command \"Set-ExecutionPolicy Unrestricted\" \u003e\u003e \"%TEMP%\\StartupLog.txt\" 2\u003e\u00261\nPowerShell %USERPROFILE%\\Desktop\\format-root-ebs.ps1 \u003e\u003e \"%TEMP%\\StartupLog.txt\" 2\u003e\u00261\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbergeron%2Faws-snapanddelete-lambda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftbergeron%2Faws-snapanddelete-lambda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbergeron%2Faws-snapanddelete-lambda/lists"}