{"id":19818768,"url":"https://github.com/sloppycoder/gcp-vm-handler","last_synced_at":"2025-02-28T15:29:34.524Z","repository":{"id":90083690,"uuid":"234548321","full_name":"sloppycoder/gcp-vm-handler","owner":"sloppycoder","description":"cloud function to start/stop VM in GCP","archived":false,"fork":false,"pushed_at":"2020-01-19T16:28:28.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-11T08:14:02.502Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/sloppycoder.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}},"created_at":"2020-01-17T12:54:16.000Z","updated_at":"2021-11-23T15:55:37.000Z","dependencies_parsed_at":"2023-03-08T17:45:19.916Z","dependency_job_id":null,"html_url":"https://github.com/sloppycoder/gcp-vm-handler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sloppycoder%2Fgcp-vm-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sloppycoder%2Fgcp-vm-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sloppycoder%2Fgcp-vm-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sloppycoder%2Fgcp-vm-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sloppycoder","download_url":"https://codeload.github.com/sloppycoder/gcp-vm-handler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241174934,"owners_count":19922414,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-12T10:16:50.992Z","updated_at":"2025-02-28T15:29:34.518Z","avatar_url":"https://github.com/sloppycoder.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Cloud function to handle start/stop VM\n\nUsage\n\n```\n# start VM associated to a token\ncurl http://\u003cfunc_url\u003e/startvm?token=\u003ctoken\u003e\n\n# stop VM associated to a token\ncurl http://\u003cfunc_url\u003e/stopvm?token=\u003ctoken\u003e\n```\n\n### Local development\n\n```\n\n# get a service account credential json file from GCP\n# place it in the current directory and name it service-account.json\n# let API library know to use it as credential\n# this step is not required when deployed into GCP\n\nexport GOOGLE_APPLICATION_CREDENTIALS=service-account.json\n\npython3 -m venv\nsource venv/bin/activate\npip install -r requirements-dev.txt\n\n# test using http trigger\nfunctions-framework --target vm_action\n\n# just run without functions framework\npython main.py\n\n\n```\n\n### Deploy into GCP\n\n```\ngcloud functions deploy vm_action --runtime python37 --trigger-http\n\n# create a scheduled job to send request to shutdown at 2am Singapore time\n\ngcloud scheduler jobs create http stop-vm \\\n    --schedule=\"05 02 * * *\" \\\n    --time-zone=\"Asia/Singapore\" \\\n    --http-method=get \\\n    --uri=\"\u003cFUNCTION_URL_WITH_PARAMETERS\u003e\"\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsloppycoder%2Fgcp-vm-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsloppycoder%2Fgcp-vm-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsloppycoder%2Fgcp-vm-handler/lists"}