{"id":20463173,"url":"https://github.com/syall/premote","last_synced_at":"2025-03-05T11:50:13.978Z","repository":{"id":126680988,"uuid":"322126316","full_name":"syall/premote","owner":"syall","description":"Project Remote CLI Tool for managing AWS EC2 Instances.","archived":false,"fork":false,"pushed_at":"2020-12-24T07:12:45.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-16T00:55:44.580Z","etag":null,"topics":["aws","cli","ec2","project","remote"],"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/syall.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-12-16T23:23:09.000Z","updated_at":"2023-06-08T09:42:50.000Z","dependencies_parsed_at":"2023-06-17T16:01:50.608Z","dependency_job_id":null,"html_url":"https://github.com/syall/premote","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/syall%2Fpremote","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syall%2Fpremote/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syall%2Fpremote/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syall%2Fpremote/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syall","download_url":"https://codeload.github.com/syall/premote/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242023194,"owners_count":20059297,"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":["aws","cli","ec2","project","remote"],"created_at":"2024-11-15T13:09:40.382Z","updated_at":"2025-03-05T11:50:13.949Z","avatar_url":"https://github.com/syall.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# premote\n\n## Overview\n\npremote is a project remote CLI tool for managing AWS EC2 instances.\n\npremote abstracts an EC2 instance under a project name. When using premote, the entire instance lifecycle is managed: creation, starting, stopping, and terminating.\n\nBy managing these events, the accruement of costs is kept to a minimum as long as there are no errors, but those fringe cases can usually be handled manually.\n\n## Motivation\n\nInstead of developing locally, premote connects the user to AWS EC2 instances where small-scale projects are essentially free. This provides several benefits:\n\n- Taking advantage of consistent development environments with Amazon Machine Images\n- Allowing low-spec devices (like Chromebooks) to act as developer machines\n\n## Usage\n\n### Installation\n\n- Clone or Download the repository locally\n- [Create a virtual environment](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/)\n- Install the packages in `requirements.txt`\n\n### Dependencies\n\npremote is implemented in [Python](https://www.python.org/) and developed using Python 3.8.6, although older versions of Python 3 will probably work.\n\n[Boto3](https://aws.amazon.com/sdk-for-python/) and its dependencies are the minimal dependencies needed to run premote, while the other dependencies in `requirements.txt` are only used in development.\n\n### Storage\n\npremote uses local storage in `~/.premote/` for individual project information, metadata for creating EC2 instances, and an EC2 private key.\n\n```text\n~/.premote/\n├── project/ # Stores \u003cproject\u003e.json files\n├── meta.json\n└── premote-keypair.pem\n```\n\n### AWS\n\nSince premote uses Boto3, premote requires AWS credentials with programmatic access.\n\nA simple guide to set up the credentials can be found in the [Boto3 Quickstart Page](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html#configuration).\n\nFor the Access Key Pair, the recommended minimal permissions is attaching the `AmazonEC2FullAccess` policy for:\n\n- Creating an EC2 Key Pair\n- Describing EC2 Instances\n- Creating EC2 Instances\n- Starting EC2 Instances\n- Stopping EC2 Instances\n- Terminating EC2 Instances\n\n## Commands\n\n### `init \u003cproject\u003e`\n\nInitializes a new Project with an EC2 Instance, then runs `start \u003cproject\u003e` to SSH into the instance.\n\nNotes:\n\n- Creating the instance takes time until status is `running`\n- Refer to [`start \u003cproject\u003e`](#start-project) for further notes\n\n### `start \u003cproject\u003e`\n\nStarts and SSHes into an existing Project EC2 Instance. The instance is stopped when the SSH session is exited properly.\n\nNotes:\n\n- Starting the instance takes time until reachable via SSH\n- Use `logout` or `Ctrl+D` to properly exit an SSH session\n- Stopping the instance takes time until status is `stopped`\n\n### `delete \u003cproject\u003e`\n\nDeletes project and terminates the associated EC2 instance.\n\nNote: Terminating the instance takes time until status is `terminated`\n\n### `config`\n\nConfigures EC2 creation metadata by prompting for the:\n\n- [Amazon Machine Image (AMI) ID](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html) (format: `ami-**`)\n- [EC2 Security Group ID](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-security-groups.html) (format: `sg-**`)\n- SSH Config File Path\n- SSH User associated with the AMI\n- [EC2 Instance Type](https://aws.amazon.com/ec2/instance-types/)\n\nIf no user input is provided, existing values are kept.\n\nNote: The EC2 Security Group requires an inbound rule for SSH\n\n## Technical Notes\n\n### AWS EC2\n\n- Every time an instance is started, a new Public DNS is assigned\n- Every time an instance is stopped, its Public DNS is released\n- Instance Status `running` is different than being reachable\n- Instance IDs persist until terminated\n- Instance Storage persists if the AMI has Elastic Block Storage (EBS)\n\n### Python 3\n\n- `argparse` for CLI arguments:\n  - `subparsers = parser.add_subparsers()`\n  - `subparsers.add_parser()`\n  - `parser.set_defaults()`\n  - `formatter_class=argparse.RawDescriptionHelpFormatter`\n  - `metavar` compared to `dest`\n  - `description` and `epilog`\n- `os` for the file system:\n  - `os.path.exists`\n  - `os.path.isfile`\n  - `os.path.isdir`\n  - `os.path.expanduser`\n  - `os.system`\n- Boto3, the AWS SDK for Python:\n  - `client`, `resource`, `waiter`\n  - Documentation for EC2 is huge and laggy\n- Miscellaneous\n  - `with` does not create a block scope\n  - `print('error msg', file=sys.stderr)`\n  - Iterate `dicts` with `.keys()`, `.values()`, `.items()`\n  - Using `**kwargs` and `\\` to write shorter lines\n  - `sys.exit()` for exiting an application\n  - Utility classes with `@staticmethod`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyall%2Fpremote","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyall%2Fpremote","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyall%2Fpremote/lists"}