{"id":20041664,"url":"https://github.com/ajithvcoder/autotrigger-aws-ec2-with-githubactions","last_synced_at":"2026-06-24T23:31:31.514Z","repository":{"id":262246211,"uuid":"886589360","full_name":"ajithvcoder/autotrigger-aws-ec2-with-githubactions","owner":"ajithvcoder","description":"Auto start and stop EC2 spot instance with github actions and cml tool","archived":false,"fork":false,"pushed_at":"2024-11-16T04:35:23.000Z","size":1593,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-20T12:37:42.742Z","etag":null,"topics":["auto-stop-start","aws-ec2","aws-spot-instance","g4dn","github-actions","gpu"],"latest_commit_sha":null,"homepage":"","language":null,"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/ajithvcoder.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-11T08:50:09.000Z","updated_at":"2024-11-12T18:01:57.000Z","dependencies_parsed_at":"2024-11-11T12:25:50.318Z","dependency_job_id":"7fa9349a-be7f-4ae3-89b3-9767704b7c4b","html_url":"https://github.com/ajithvcoder/autotrigger-aws-ec2-with-githubactions","commit_stats":null,"previous_names":["ajithvcoder/autotrigger-aws-ec2-with-githubactions"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ajithvcoder/autotrigger-aws-ec2-with-githubactions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2Fautotrigger-aws-ec2-with-githubactions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2Fautotrigger-aws-ec2-with-githubactions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2Fautotrigger-aws-ec2-with-githubactions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2Fautotrigger-aws-ec2-with-githubactions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajithvcoder","download_url":"https://codeload.github.com/ajithvcoder/autotrigger-aws-ec2-with-githubactions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2Fautotrigger-aws-ec2-with-githubactions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34753781,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-24T02:00:07.484Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["auto-stop-start","aws-ec2","aws-spot-instance","g4dn","github-actions","gpu"],"created_at":"2024-11-13T10:47:26.725Z","updated_at":"2026-06-24T23:31:31.496Z","avatar_url":"https://github.com/ajithvcoder.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"### Auto-Trigger-AWS-EC2-with-GPU\n\n**Contents**\n\n1. [Request AWS Spot Instance](#request-aws-spot-instance)\n2. [Credentials Configuration](#credentials-configuration)\n3. [Github Workflow](#github-workflow)\n4. [Reference](#reference)\n\n\n### Request AWS Spot Instance\n\n*Note: This spot request is optional you can trigger cml launcher even without this spot instance type*\n\n- Since spot instance is budget friendly i am explaining this blog with spot instance example\n\n- Go to Searvice Quota -\u003e AWS Services -\u003e Amazon Elastic Compute Client(Amazon Ec2)\n- Change the region to Mumbai ap-south-1 (nearest to your location)\n\n    ![ec2_quota](./assets/snap_aws_ec2_service_quota.png)\n\n- I need g4dn.xlarge so i am going to request \"All G and VT Spot Instance Requests\" in Quota name.\n\n    ![g_and_t_instance](./assets/snap_g_and_t_instance.png)\n\n- After clicking \"All G and VT Spot Instance Requests\" name you need to click \"Request increase at account level\" and you can give 8 or 16 or 32 as input.\n    ![request_limit](./assets/snap_request_limit.png)\n\n    Note: Spot instance takes 1 week for approval but the GPU cost would be 1/10 of the original gpu cost. Dont leave reading this blog because of that for running this experiment without spot instance takes less than 1 USD only.\n\n### Credentials Configuration\n\nNote: We can create roles or policies and proceed for specific permission I didnt explore it.\n\n- Go to \"I AM\" dashboard and click the user that has account level permission\n\n    ![request_limit](./assets/snap_iam_dashboard.png)\n\n- Make sure it has \"AdministratorAccess\" perimission\n\n    ![request_limit](./assets/snap_permission.png)\n\n- Click \"Create Access Key\" -\u003e \"Application running outside AWS\" -\u003e \"Create access key\" -\u003e Download .csv file\n\n    ![request_limit](./assets/snap_access_permission.png)\n\n- if you look at .csv file `Access key ID` and `Secret access key`\n\n**Github Repo**\n\n- Go to github repo where the workflow is going to run. Go to Settings -\u003e \"Secret and variables\" -\u003e Actions -\u003e New repository secrets\n\n- Give AWS_ACCESS_KEY_ID and its value like below and cliek `Add secret` from your .csv file\n\n    ![request_limit](./assets/snap_secret_store.png)\n\n- Similarly store `AWS_SECRET_ACCESS_KEY` in `repository secrets`\n\n\n- Store the fine_graded_personal-access_token generated got from your github account in the name `PERSONAL_ACCESS_TOKEN`. To run workflow you need additional privilage so better enable every checkbox when creating fine_graded_pak\n\n    ![request_limit](./assets/snap_after_entering.png)\n\n### Github Workflow\n\nThere are many tools to start and stop AWS instances and services.\n\n- We are going to use [cml-runner](https://github.com/iterative/setup-cml?tab=readme-ov-file#setup-cml-action) to trigger EC2 spot instance. Below is the trigger command.\n\n```\ncml runner launch --cloud=aws --name=session-08 \\\n    --cloud-region=ap-south-1 --cloud-type=g4dn.xlarge --cloud-hdd-size=64 \\\n    --cloud-spot --single --labels=cml-gpu --idle-timeout=100\n```\n\n`--idle-timeout=100` means after 100 seconds of idle time the instance shuts down\n\n**Instance starts**\n\n![request_limit](./assets/snap_trigger_ec2_spot.png)\n\n![request_limit](./assets/snap_spot_proof.png)\n\n- With some verification methods `http://169.254.169.254/latest/meta-data/instance-type` we can confirm if we had triggered the similar instance and if GPU is also attached to it. You can see that its a g4dn.xlarge instance\n\n![request_limit](./assets/snap_verify_instance.png)\n\n\n- Since aws cli is not installed by default as we are not using specific CLI we can instance aws cli manually and configure. Refer workflow file for it\n\n\n- After worflow execution by 100 seconds the EC2 instance shutdown and after complete shutdown within 5 minutes spot request also gets close. \n\n- Note: Ensure your spot request also closes properly else it may restart your instance again due to improper setting.\n\n**EC2 shutdown**\n\n![request_limit](./assets/snap_ec2_shutdown.png)\n\n**Spot request shutdown**\n\n![request_limit](./assets/snap_spot_request_shut_down.png)\n\nJob Run link - [here](https://github.com/ajithvcoder/autotrigger-aws-ec2-with-githubactions/actions/runs/11777520687/job/32802085220)\n\n### Reference\n\n1. [cml-example-cloud-gpu](https://github.com/iterative-test/cml-example-cloud-gpu)\n2. [cml-runner](https://cml.dev/doc/ref/runner)\n3. [cml-repo-setup](https://github.com/iterative/setup-cml?tab=readme-ov-file#setup-cml-action)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajithvcoder%2Fautotrigger-aws-ec2-with-githubactions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajithvcoder%2Fautotrigger-aws-ec2-with-githubactions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajithvcoder%2Fautotrigger-aws-ec2-with-githubactions/lists"}