{"id":24517787,"url":"https://github.com/fstab50/ec2cli","last_synced_at":"2025-03-15T11:11:07.442Z","repository":{"id":172339658,"uuid":"43451191","full_name":"fstab50/ec2cli","owner":"fstab50","description":"Utility for managing Amazon Web Services' EC2 Service from the Linux command line","archived":false,"fork":false,"pushed_at":"2023-06-04T02:10:36.000Z","size":31163,"stargazers_count":1,"open_issues_count":10,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-22T01:36:44.839Z","etag":null,"topics":["amazon-ec2-utilities","amazon-web-services","aws","aws-cli","cli-utilities","ebs-snapshots","ebs-volumes","ec2","ec2-instance","ec2-snapshot","ec2-spot","ec2-spot-instances","iam-permissions","screenshot","security-groups","subnets","vpc"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fstab50.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2015-09-30T18:30:12.000Z","updated_at":"2021-05-23T14:18:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"d334ab7d-220b-43fb-9165-cbf7a62ea270","html_url":"https://github.com/fstab50/ec2cli","commit_stats":null,"previous_names":["fstab50/ec2cli"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fstab50%2Fec2cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fstab50%2Fec2cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fstab50%2Fec2cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fstab50%2Fec2cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fstab50","download_url":"https://codeload.github.com/fstab50/ec2cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243719399,"owners_count":20336607,"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":["amazon-ec2-utilities","amazon-web-services","aws","aws-cli","cli-utilities","ebs-snapshots","ebs-volumes","ec2","ec2-instance","ec2-snapshot","ec2-spot","ec2-spot-instances","iam-permissions","screenshot","security-groups","subnets","vpc"],"created_at":"2025-01-22T01:35:15.958Z","updated_at":"2025-03-15T11:11:07.434Z","avatar_url":"https://github.com/fstab50.png","language":"Shell","readme":"\u003ca name=\"top\"\u003e\u003c/a\u003e\n* * *\n# EC2cli - Utility for Managing Amazon EC2\n* * *\n\n## Contents\n\n* [**About**](#about-this-repository)\n\n* [**Summary**](#summary)\n\n* [**Dependencies**](#dependencies)\n\n* [**Program Options**](#program-options)\n\n* [**Installation**](#installation)\n  * [Ubuntu, Linux Mint, Debian-based Distributions](#debian-distro-install)\n  * [Redhat, CentOS, Fedora](#redhat-distro-install)\n  * [Amazon Linux 2](#amzn2-distro-install)\n\n* [**Configuration**](#configuration)\n\n* [**Verify Your Configuration**](#verify-your-configuration)\n\n* [**Identity and Access Management (IAM) Permissions**](#iam-permissions)\n\n* [**Build Options**](#build-options)\n\n* [**Screenshots**](#screenshots)\n  * [`list` Command](#screenshots0)\n  * [`list --all` Command](#screenshots1)\n  * [`run` Command](#screenshots2)\n  * [ `--tags` Resource Option](#screenshots3)\n  * [EC2 Spot Price Utility](#screenshots4)\n\n* [**Author \u0026 Copyright**](#author--copyright)\n\n* [**License**](#license)\n\n* [**Disclaimer**](#disclaimer)\n\n--\n\n[back to the top](#top)\n\n* * *\n\n## About this repository\n\n* Purpose: \t\tCLI utilities for use with Amazon Web Services (AWS)\n* Version:\t2.4.15\n* Repo: \t\thttps://github.com/fstab50/ec2cli\n\n--\n\n[back to the top](#top)\n\n* * *\n## Summary\n\nEC2cli was developed to make life easier when working with AWS services in a cli environment.  EC2cli utilizes AWS' cli tools to enable you to send signed requests to Amazon's API to perform uses cases typically  accomplished using the console interface.  EC2cli will save time and effort to perform operations such as taking a snapshot or querying the state of EC2 instances to determine which are running.\n\nWhile it is clear that accomplishing the ec1cli's functionality with the AWS ruby or python SDK's may be cleaner, ec2cli was developed in bash to make it easy for system administrators and solution architects to modify ec2cli for each's respective use cases.\n\n_Dependency Note_:  ec2cli was developed and tested under bash. Some functionality may work with other shells; however, your mileage may vary.\n\n[![instances](./assets/ec2cli-list-instances.png)](https://images.awspros.world/ec2cli/ec2cli-list-instances.png)\n\n(See [Screenshots](#screenshots) section below)\n\n--\n\n[back to the top](#top)\n\n* * *\n\n## Dependencies\n\n[ec2cli](https://github.com/fstab50/ec2cli) requires the following to function correctly:\n\n- A modern Linux distribution with bash (4.x+)\n- [Python version 3.6+](https://docs.python.org/3/)\n- Appropriate [Identity and Access Management (IAM) Permissions](#iam-permissions) to access your Amazon Web Services account.\n\n\n\u003e **Important**:\n    _For proper operation, at a minimum this program requires the *default awscli user account* should have read-only\n     IAM permissions to all EC2 describe functions._\n\u003e\n\n\n- Configuration of [Amazon Web Services CLI tools](https://github.com/aws/aws-cli) (awscli).  After installation, follow this [configuration guide](#configuration) to set up the awscli for Bash.\n- [jq](https://stedolan.github.io/jq), a json parser generally available from your distribution repo\n- Standard linux utilities:\n    * grep\n    * awk\n    * sed\n    * cat\n    * hostname\n\n--\n\n[back to the top](#top)\n\n* * *\n\n## Program Options ##\n\n```bash\n\t$ ec2cli --help\n```\n\n[![help](./assets/ec2cli-help.png)](https://images.awspros.world/ec2cli/ec2cli-help.png)\n\n\n### Notes: ###\n\n* **RESOURCE** is required. Represents a disparate AWS resource. Only 1 resource at a time is supported.\n\n* **COMMAND** is optional. If omitted, ec2cli defaults to the `list` command and lists details of the EC2 resource specified by the OPTION parameter.\n\n* **REGIONCODE** is optional. If omitted, ec2cli defaults to the AWS default region defined in the `AWS_DEFAULT_REGION` environment variable (if present); or alternately, the awscli config file.\n\n* `create` and `run` commands currently have support for limited resource types. Update your local repo frequently to enable additional resource types as additional types are added.\n\n--\n\n[back to the top](#top)\n\n* * *\n## Installation ##\n* * *\n\n\u003ca name=\"debian-distro-install\"\u003e\u003c/a\u003e\n### Ubuntu, Linux Mint, Debian variants  (Python 3.6+)\n\nThe easiest way to install **ec2cli** on debian-based Linux distributions is via the debian-tools package repository:\n\n\n1. Open a command line terminal.\n\n    [![deb-install0](./assets/deb-install-0.png)](http://images.awspros.world/ec2cli/deb-install-0.png)\n\n2. Download and install the repository definition file\n\n    ```bash\n    $ sudo apt install wget\n    ```\n\n    ```bash\n    $ wget http://awscloud.center/deb/debian-tools.list\n    ```\n\n    [![deb-install1](./assets/deb-install-1.png)](http://images.awspros.world/ec2cli/deb-install-1.png)\n\n    ```bash\n    $ sudo chown 0:0 debian-tools.list \u0026\u0026 sudo mv debian-tools.list /etc/apt/sources.list.d/\n    ```\n\n3. Install the package repository public key on your local machine\n\n    ```bash\n    $ wget -qO - http://awscloud.center/keys/public.key | sudo apt-key add -\n    ```\n\n    [![deb-install2](./assets/deb-install-2.png)](http://images.awspros.world/ec2cli/deb-install-2.png)\n\n4. Update the local package repository cache\n\n    ```bash\n    $ sudo apt update\n    ```\n\n5. Install **ec2cli** os package\n\n    ```bash\n    $ sudo apt install ec2cli\n    ```\n\n    [![deb-install3a](./assets/deb-install-3a.png)](http://images.awspros.world/ec2cli/deb-install-3a.png)\n\n    Answer \"y\":\n\n    [![deb-install3b](./assets/deb-install-3b.png)](http://images.awspros.world/ec2cli/deb-install-3b.png)\n\n\n6. Verify Installation\n\n    ```bash\n    $ apt show ec2cli\n    ```\n\n    [![apt-show](./assets/deb-install-4.png)](http://images.awspros.world/ec2cli/deb-install-4.png)\n\n--\n\n[back to the top](#top)\n\n* * *\n\n\u003ca name=\"redhat-distro-install\"\u003e\u003c/a\u003e\n### Redhat, CentOS  (Python 3.6+), Fedora (Python 3.7+)\n\nThe easiest way to install **ec2cli** on redhat-based Linux distributions is via the developer-tools package repository:\n\n1. Open a command line terminal.\n\n    [![rpm-install0](./assets/rpm-install-0.png)](http://images.awspros.world/ec2cli/rpm-install-0.png)\n\n2. Install the official epel package repository\n\n    ```bash\n    $ sudo yum install epel-release\n    ```\n\n2. Download and install the repo definition file\n\n    ```bash\n    $ sudo yum install wget\n    ```\n\n    [![rpm-install1](./assets/rpm-install-1.png)](http://images.awspros.world/ec2cli/rpm-install-1.png)\n\n    ```bash\n    $ wget http://awscloud.center/rpm/developer-tools.repo\n    ```\n\n    [![rpm-install2](./assets/rpm-install-2.png)](http://images.awspros.world/ec2cli/rpm-install-2.png)\n\n    ```bash\n    $ sudo chown 0:0 developer-tools.repo \u0026\u0026 sudo mv developer-tools.repo /etc/yum.repos.d/\n    ```\n\n    [![rpm-install2b](./assets/rpm-install-2b.png)](http://images.awspros.world/ec2cli/rpm-install-2b.png)\n\n\n3. Delete the local repository cache, then Update the cache with new package references\n\n    ```bash\n    $ sudo rm -fr /var/cache/yum\n    $ sudo yum update -y\n    ```\n\n4. Install the **ec2cli** os package\n\n    ```bash\n    $ sudo yum install ec2cli\n    ```\n\n    [![rpm-install3](./assets/rpm-install-3.png)](http://images.awspros.world/ec2cli/rpm-install-3.png)\n\n\n    Answer \"y\":\n\n    [![rpm-install4](./assets/rpm-install-4.png)](http://images.awspros.world/ec2cli/rpm-install-4.png)\n\n\n5. Verify Installation\n\n    ```bash\n    $ yum info ec2cli\n    ```\n\n    [![rpm-install5](./assets/rpm-install-5.png)](http://images.awspros.world/ec2cli/rpm-install-5.png)\n\n--\n\n[back to the top](#top)\n\n* * *\n\u003ca name=\"amzn2-distro-install\"\u003e\u003c/a\u003e\n### Amazon Linux 2\n\nRedhat Package Manager (RPM) format used by Amazon Linux under development.  Check [amzn2.awscloud.center](http://s3.us-east-2.amazonaws.com/amzn2.awscloud.center/index.html) page for updates.\n\n--\n\n[back to the top](#top)\n\n\n* * *\n\n## Configuration ##\n\n1. You will have to configure the Amazon Web Servies comand line interface before attempting to use **ec2cli**:\n\na. Run the _aws configure_ command:\n\n```bash\n$ aws configure\n   AWS Access Key ID: foo\n   AWS Secret Access Key: bar\n   Default region name [us-west-2]: us-west-2\n   Default output format [None]: json\n```\n\nb. Optionally, define a profile for a specific user:\n\n```bash\n  $ aws configure --profile testuser\n    AWS Access Key ID: footestuser\n    AWS Secret Access Key: bartestuser\n    Default region name [us-west-2]: us-west-2\n    Default output format [None]: json\n```\n\nc. Configure bash command completion:  \tYou'll want to enable command completion to make awscli\n\tcommands easy to type and recall.  After installing awscli,\n\tadd the following to your .bashrc or .bash_profile:\n\n```bash\n  # .bashrc\n\tcomplete -C aws_completer aws\n```\n\n2. Next, configure [IAM policy permissions](#iam-permissions) for the user profile which will generally be used with **ec2cli**.\n\n--\n\n[back to the top](#top)\n\n* * *\n\n### Verify Your Configuration\n\nAfter completing the above Installation and Configuration sections, verify your configuration:\n\n```bash\n$ aws --version\n```\n\nOutput:\n\n```bash\n$  aws-cli/1.19.44 Python/3.8.5 Linux/5.6.0-1052-oem botocore/1.20.44\n```\n\n**Note**: Python and Kernel versions will depend upon your system parameters\n\n--\n\n[back to the top](#top)\n\n* * *\n\n## IAM Permissions ##\n\n#### ec2cli Required Permissions ####\nYou'll need appropriate IAM permissions to execute ec2cli.\n\n```json\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Effect\": \"Allow\",\n            \"Action\": \"ec2:Describe*\",\n            \"Resource\": \"*\"\n        },\n        {\n            \"Effect\": \"Allow\",\n            \"Action\": \"elasticloadbalancing:Describe*\",\n            \"Resource\": \"*\"\n        },\n        {\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"cloudwatch:ListMetrics\",\n                \"cloudwatch:GetMetricStatistics\",\n                \"cloudwatch:Describe*\"\n            ],\n            \"Resource\": \"*\"\n        },\n        {\n            \"Effect\": \"Allow\",\n            \"Action\": \"autoscaling:Describe*\",\n            \"Resource\": \"*\"\n        },\n        {\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"ec2:AttachVolume\",\n                \"ec2:CreateKeyPair\",\n                \"ec2:CreateSecurityGroup\",\n                \"ec2:CreateSnapshot\",\n                \"ec2:DeleteSnapshot\",\n                \"ec2:DetachVolume\",\n                \"ec2:RunInstances\",\n                \"ec2:StartInstances\",\n                \"ec2:StopInstances\"\n            ],\n            \"Resource\": [\n                \"*\"\n        ]\n        }\n    ]\n}\n\n```\n\nYou can grab a read-only version of the policy [here](./policies/iampolicy-EC2-quickview.json) or the full IAM policy which allows changes to resources [here](./policies/iampolicy-EC2-full.json).\n\n--\n\n[back to the top](#top)\n\n* * *\n\n## Build options\n\n**[GNU Make](https://www.gnu.org/software/make) Targets**.  If you wish to use this project to compile your own Linux installation pa kages, type the following to display the available make targets from the root of the project:\n\n```bash\n    $  make help\n```\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"http://images.awspros.world/ec2cli/make-help.png\" target=\"_blank\"\u003e\u003cimg src=\"./assets/make-help.png\"\u003e\n\u003c/p\u003e\n\n--\n\n[back to the top](#top)\n\n* * *\n## Screenshots ##\n* * *\n\u003ca name=\"screenshots0\"\u003e\u003c/a\u003e\n#### [Screenshots](#screenshots) / ec2cli `list` command\n\nList command displays AWS resource details for your AWS default region if no region specified. If an alternate region given as a parameter, displays resource details for the specified region.\n\n\n```bash\n$ ec2cli --instances  --region us-west-2    # list ec2 instances\n```\n[![instances](./assets/ec2cli-list-instances.png)](https://images.awspros.world/ec2cli/ec2cli-list-instances.png)\n\n```bash\n$ ec2cli --volumes    # list ebs volume details, AWS default region (us-west-2)\n```\n\n[![volumes](./assets/ec2cli-list-volumes.png)](https://images.awspros.world/ec2cli/ec2cli-list-volumes.png)\n\n\n```bash\n$ ec2cli --snapshots  --region us-west-2     # list snapshots\n```\n[![snapshots](./assets/ec2cli-list-snapshots.png)](https://images.awspros.world/ec2cli/ec2cli-list-snapshots.png)\n\n```bash\n$ ec2cli --secgroups    # list security group details, AWS default region (us-west-2)\n```\n[![securitygroups](./assets/ec2cli-list-securitygroups.png)](https://images.awspros.world/ec2cli/ec2cli-list-securitygroups.png)\n\n--\n\n[back to the top](#top)\n\n* * *\n\u003ca name=\"screenshots1\"\u003e\u003c/a\u003e\n#### [Screenshots](#screenshots) / ec2cli `list` + `--all` command\n\nList command displays AWS resource details for your AWS default region if no region specified. If the `--all` option is used in conjunction with the `list` command, ec2cli audits all the regions to which your AWS account has access, identifying the resources specified by the RESOURCES parameter.  Examples:\n\n\n```bash\n$ ec2cli --secgroups list --all    # list all security groups across all AWS regions\n```\n[![secgroups](./assets/secgroups-all.png)](https://images.awspros.world/ec2cli/secgroups-all.png)\n\n```bash\n$ ec2cli --vpcs list --all   # list all VPC's in all AWS regions\n```\n\n[![vpcs](./assets/vpcs-all.png)](https://images.awspros.world/ec2cli/vpcs-all.png)\n\n--\n\n[back to the top](#top)\n\n* * *\n\n\u003ca name=\"screenshots2\"\u003e\u003c/a\u003e\n#### [Screenshots](#screenshots) / ec2cli `run` command\n\n*Note: this utility may also be used to automate login to a running EC2 instance*\n*as well as starting a stopped instance. See step 2. (below)*\n\n```bash\n$ ec2cli --instances run    # run/ log on to EC2 instances in default region\n```\n1.Select from list of instance choices:\n\n[![instances](./assets/start-instance_01.png)](https://images.awspros.world/ec2cli/start-instance_01.png)\n\n2.After instance is chosen, ec2cli performs a network access check:\n\n  * Access check sources the security group and validates IPs listed in the group against your local IP.\n  * _Note_: if the instance you chose is already running, the ec2cli moves immediately to authentication (Step 4).\n\n[![instances](./assets/start-instance_02.png)](https://images.awspros.world/ec2cli/start-instance_02.png)\n\n\n3.If network access check succeeds, the ec2 wait function is called to prevent login until the instance starts.\n\n[![instances](./assets/start-instance_03.png)](https://images.awspros.world/ec2cli/start-instance_03.png)\n\n4.Authentication start:\n\n  * Public IP and ssh key name are sourced from instance json data via api call.\n  * The ssh key is then located on your local machine in the dir specified by the ``$SSH_KEYS`` env variable.\n\n[![instances](./assets/start-instance_04.png)](https://images.awspros.world/ec2cli/start-instance_04.png)\n\n5.Login established (entire start sequence shown)\n\n[![instances](./assets/start-instance_05.png)](https://images.awspros.world/ec2cli/start-instance_05.png)\n\n--\n\n[back to the top](#top)\n\n* * *\n\n\u003ca name=\"screenshots3\"\u003e\u003c/a\u003e\n#### [Screenshots](#screenshots) / ec2cli --tags \u003cresourceId\u003e\n\nDisplay all tags attached to an EC2 resource by following the steps below:\n\n1. Enter the ```--tags``` parameter after the main executable:\n\n```bash\n$  ec2cli --tags\n```\n\n2.  Hit the \u003ctab\u003e key twice to display a list of available EC2 resource Ids:\n\n```bash\n$ ec2cli --tags \u003ctab\u003e\u003ctab\u003e\n```\n[![tags1](./assets/tags-completion.png)](https://images.awspros.world/ec2cli/tags-completion.png)\n\n3. Choose a resource id by typing the first few characters.  Then hit the \u003ctab\u003e key.\n\n* Example 1:  Tags associated with a specific EC2 machine instance:\n\n[![tags2](./assets/tags-instance.png)](https://images.awspros.world/ec2cli/tags-instance.png)\n\n* Example 2:  Tags associated with an EC2 snapshot:\n\n[![tags3](./assets/tags-snapshot.png)](https://images.awspros.world/ec2cli/tags-snapshot.png)\n\n--\n\n[back to the top](#top)\n\n* * *\n\n\u003ca name=\"screenshots4\"\u003e\u003c/a\u003e\n#### [Screenshots](#screenshots) / Spot Price Utility\n\n\n[Screenshots (continued)](./README_spot.md)\n\n--\n\n[back to the top](#top)\n\n* * *\n\n## Author \u0026 Copyright\n\nAll works contained herein copyrighted via below author unless work is explicitly noted by an alternate author.\n\n* Copyright Blake Huber, All Rights Reserved.\n\n--\n\n[back to the top](#top)\n\n* * *\n\n## License\n\n* Software contained in this repo is licensed under the [license agreement](./LICENSE.md).  You may display the license and copyright information by issuing the following command:\n\n```bash\n$ ec2cli --version\n```\n\n[![version](./assets/version-copyright.png)](https://images.awspros.world/ec2cli/version-copyright.png)\n\n--\n\n[back to the top](#top)\n\n* * *\n\n## Disclaimer\n\n*Code is provided \"as is\". No liability is assumed by either the code's originating author nor this repo's owner for their use at AWS or any other facility. Furthermore, running function code at AWS may incur monetary charges; in some cases, charges may be substantial. Charges are the sole responsibility of the account holder executing code obtained from this library.*\n\nAdditional terms may be found in the complete [license agreement](./LICENSE.md).\n\n--\n\n[back to the top](#top)\n\n* * *\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffstab50%2Fec2cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffstab50%2Fec2cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffstab50%2Fec2cli/lists"}