{"id":18755998,"url":"https://github.com/osama-yusuf/aws-ec2-status-controller","last_synced_at":"2026-04-13T17:33:40.773Z","repository":{"id":162116704,"uuid":"573874727","full_name":"Osama-Yusuf/AWS-EC2-Status-Controller","owner":"Osama-Yusuf","description":"This script provisions, scan, start, stop, and terminate instances in AWS, then notify you by mail if there's any running instance.","archived":false,"fork":false,"pushed_at":"2022-12-14T20:02:50.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-20T13:55:58.519Z","etag":null,"topics":["aws","aws-region-finder","bash-script","ec2-instance"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Osama-Yusuf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-12-03T17:53:11.000Z","updated_at":"2024-04-09T00:11:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"de4b160b-da74-466b-a690-c83882e48dc9","html_url":"https://github.com/Osama-Yusuf/AWS-EC2-Status-Controller","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Osama-Yusuf/AWS-EC2-Status-Controller","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Osama-Yusuf%2FAWS-EC2-Status-Controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Osama-Yusuf%2FAWS-EC2-Status-Controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Osama-Yusuf%2FAWS-EC2-Status-Controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Osama-Yusuf%2FAWS-EC2-Status-Controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Osama-Yusuf","download_url":"https://codeload.github.com/Osama-Yusuf/AWS-EC2-Status-Controller/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Osama-Yusuf%2FAWS-EC2-Status-Controller/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31762587,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T15:25:13.801Z","status":"ssl_error","status_checked_at":"2026-04-13T15:25:09.162Z","response_time":93,"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-region-finder","bash-script","ec2-instance"],"created_at":"2024-11-07T17:34:48.733Z","updated_at":"2026-04-13T17:33:40.736Z","avatar_url":"https://github.com/Osama-Yusuf.png","language":"Shell","funding_links":["https://paypal.me/OsamaYusuf","https://www.buymeacoffee.com/OsamaYusuf"],"categories":[],"sub_categories":[],"readme":"# AWS EC2 Status Controller\n**AWS EC2 Status Controller** is a bunch of **BASH** scripts for scanning, starting, stopping, and terminating instances in Amazon Web Services.\n\nif there's any instance running, it will send you a mail to notify you.\n\nyou can also use it to create a new EC2 instance with specific settings for region, instance type, key pair, volume size, security group, and instance name.\n\nTake a look at the [GitHub project page](https://github.com/Osama-Yusuf/AWS-EC2-Status-Controller).\n\n## Features\n\n[**aws_ec2.sh:**](#1-aws_ec2sh)\n* Scan all regions for launched instances (whether they are running or not)\n* Saves scanned instances to a file for later use\n* Check, start, stop and terminate specific instances or all in a specific region \n* Check for lanched instances by regions and print their info (instance id, instance type, state, public IP, private IP)\n* prints public IP and private IP of instances\n* prints instance id, intance type and state of instances\n\n[**notify_ec2.sh:**](#2-notify_ec2sh)\n* send mail to notify you if there's any instance running with the ability to change this to notify you only if there's any large/xlarge instance running\n* you can create a cronjob to run this script every 12HRS or on reboot to mail you if there's any instance running\n\n[**provision_ec2.sh:**](#3-provision_ec2sh)\n* Provision a new EC2 instance with custom region, instance type, key pair, volume_size, security group, and the name of the instance\n* creates a new key pair if it the one you specified as 3rd argument doesn't exist and saves it in the current directory or the directory you passed as the third argument\n* creates a new security group with the name you passed as the fifth argument and add inbound rule to allow all traffic from your ip only to the instance\n* creates a new volume with the size you passed as the fourth argument and attach it to the instance\n* creates a name you passed as the fifth argument for the instance\n\n---\n\n## Getting started:\n\n### 1. aws_ec2.sh:\n### Install:\n```bash\ncurl \"https://raw.githubusercontent.com/Osama-Yusuf/AWS-EC2-Status-Controller/main/aws_ec2.sh\" -o aws_ec2.sh \u0026\u0026 chmod +x aws_ec2.sh\nsudo mv aws_ec2.sh /usr/local/bin/ec2\n```\n\n### Usage:\n```\n1. aws_ec2 scan save\n2. aws_ec2 check [region]\n3. aws_ec2 [start|stop|terminate|ip] [region] [instance_id]\n\naws_ec2\n   scan                                scans all regions and saves only scan result in $rgs_dir/scan\n   scan save                           scans and saves the instances ids for further use in $rgs_dir\n   \n   regions                             lists all saved regions, but you must first scan and save the instances\n   [region]                            print info about instances inside passed region\n   \n   [command] [region] [instance_id]    [start|stop|terminate|ip|check] but you must first scan and save the instances\n\nEg: aws_ec2 start us-east-1                         starts all instances in us-east-1\nEg: aws_ec2 start us-east-1 i-050b7d36ad76bddea     starts a specific instance in us-east-1\n```\n\n### 2. notify_ec2.sh\n### Install:\n```bash\ncurl \"https://raw.githubusercontent.com/Osama-Yusuf/AWS-EC2-Status-Controller/main/notify_ec2.sh\" -o notify_ec2.sh \u0026\u0026 chmod +x notify_ec2.sh\nsudo mv notify_ec2.sh /usr/local/bin/notify_ec2\n```\n\n### Usage:\nThis will send you a mail if there's any instance running\n```bash\nnotify_ec2 yourmail@gmail.com\n```\nTo create a cronjob to execute this script every 12HRS or on reboot to notify you if there's any instance running, you must do the following first:\n\na- execute the script for the first time to install any missing dependencies and to configure ssmtp\n```bash\n./notify_ec2.sh yourmail@gmail.com\nOR \nnotify_ec2 yourmail@gmail.com\n```\nb- To avoid cronjob errors delete unnecessary parts of script copy paste the following in /usr/local/bin/notify_ec2:\n```bash\nec2 scan save\ninst_path=\"$HOME/running_instances.txt\"\nrunning_inst=$(grep running ~/.aws/regions/scan | awk '{print $2 \" - \" $7}' | sort | uniq -c | sed 's/,//g')\ndate=$(date +%F)\necho -e \"$date:\\n$running_inst\\n----------------------------------------\" \u003e\u003e $inst_path\nif [ -n \"$running_inst\" ]; then\n    echo \"Sending email to $1...\"\n    echo -e \"The following AWS instance are currently running:\\n\\n$(cat $inst_path)\" | mail -s \"Warning running instances\" $1\nelse\n    echo \"there're no instance running in aws\"\nfi\n```\nc- open crontab editor with vim\n```bash\ncrontab -e\n```\nd- add any line of the following lines in the vim editor\n```bash\n0 */12 * * * /bin/bash /usr/local/bin/notify_ec2 yourmail@gmail.com \u003e\u003e /home/\u003cyour_user\u003e/output.txt\n@reboot /bin/bash /usr/local/bin/notify_ec2 yourmail@gmail.com \u003e\u003e /home/\u003cyour_user\u003e/output.txt\n```\n\n### 3. provision_ec2.sh:\n### Install:\n```bash\ncurl \"https://raw.githubusercontent.com/Osama-Yusuf/AWS-EC2-Status-Controller/main/provision_ec2.sh\" -o provision_ec2.sh \u0026\u0026 chmod +x provision_ec2.sh\nsudo mv provision_ec2.sh /usr/local/bin/provision\n```\n\n### Usage:\nThis will provision ec2 with custom region, instance type, key pair, volume_size, security group, and the name of the instance\n```bash\nprovision \u003c1-region\u003e \u003c2-instance_type\u003e \u003c3-key_name.pem\u003e \u003c4-volume_size\u003e \u003c5-tag\u003e\n```\nNP: the numbers indicated above is just to help you write the values in the right order, do not write them before the value\n\nE.g.:\n```bash\nprovision us-east-1 t2.micro key_name.pem 20 my_instance\n```\n---\n\n## Tested Environments\n\n* Ubuntu 20.04.\n\n   If you have successfully tested this script on others systems or platforms please let me know!\n\n---\n\n## Support \n\n If you want to support this project, please consider donating:\n * PayPal: https://paypal.me/OsamaYusuf\n * Buy me a coffee: https://www.buymeacoffee.com/OsamaYusuf\n * ETH: 0x507bF8931b534a81Ced18FDf8fc5BE4Daf08332B\n\n---\n\n* `By Osama-Yusuf`\n* `Thanks for reading`\n\n-------\n##### Report bugs for \"AWS-EC2-Status-Controller\"\n* `osama9mohamed5@gmail.com`\n ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosama-yusuf%2Faws-ec2-status-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fosama-yusuf%2Faws-ec2-status-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosama-yusuf%2Faws-ec2-status-controller/lists"}